-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for remote database connection (#13)
- Loading branch information
1 parent
27eb76a
commit 4b15af3
Showing
22 changed files
with
359 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace Libsql.Client.Tests; | ||
|
||
public class EmbeddedReplicaTests | ||
{ | ||
[Fact(Skip = "Not implemented")] | ||
public async Task CanConnectAndQueryReplicaDatabase() | ||
{ | ||
var db = await DatabaseClient.Create(opts => { | ||
opts.Url = Environment.GetEnvironmentVariable("LIBSQL_TEST_URL") ?? throw new InvalidOperationException("LIBSQL_TEST_URL is not set"); | ||
opts.AuthToken = Environment.GetEnvironmentVariable("LIBSQL_TEST_AUTH_TOKEN"); | ||
opts.ReplicaPath = "/home/tvandinther/code/libsql-client-dotnet/replica.db"; | ||
}); | ||
|
||
await db.Sync(); | ||
|
||
var rs = await db.Execute("SELECT COUNT(*) FROM albums"); | ||
|
||
var count = rs.Rows.First().First(); | ||
var value = Assert.IsType<Integer>(count); | ||
Assert.Equal(347, value.Value); | ||
} | ||
|
||
[Fact(Skip = "Not implemented")] | ||
public async Task CanCallSync() | ||
{ | ||
var db = await DatabaseClient.Create(opts => { | ||
opts.Url = Environment.GetEnvironmentVariable("LIBSQL_TEST_URL") ?? throw new InvalidOperationException("LIBSQL_TEST_URL is not set"); | ||
opts.AuthToken = Environment.GetEnvironmentVariable("LIBSQL_TEST_AUTH_TOKEN"); | ||
opts.ReplicaPath = "/home/tvandinther/code/libsql-client-dotnet/replica.db"; | ||
}); | ||
|
||
await db.Sync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Libsql.Client.Tests; | ||
|
||
public class RemoteTests | ||
{ | ||
[Fact] | ||
public async Task CanConnectAndQueryRemoteDatabase() | ||
{ | ||
var db = await DatabaseClient.Create(opts => { | ||
opts.Url = Environment.GetEnvironmentVariable("LIBSQL_TEST_URL") ?? throw new InvalidOperationException("LIBSQL_TEST_URL is not set"); | ||
opts.AuthToken = Environment.GetEnvironmentVariable("LIBSQL_TEST_AUTH_TOKEN"); | ||
}); | ||
|
||
var rs = await db.Execute("SELECT COUNT(*) FROM tracks"); | ||
|
||
var count = rs.Rows.First().First(); | ||
var value = Assert.IsType<Integer>(count); | ||
Console.WriteLine(value.Value); | ||
Assert.Equal(3503, value.Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Libsql.Client{ | ||
internal enum DatabaseType | ||
{ | ||
Memory, | ||
File, | ||
Remote, | ||
EmbeddedReplica | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Libsql.Client.Extensions; | ||
|
||
namespace Libsql.Client | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.