Skip to content

Commit aaba345

Browse files
committed
chore: test with CPP lib
1 parent bfc8923 commit aaba345

File tree

5 files changed

+37
-3
lines changed

5 files changed

+37
-3
lines changed

spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native/Google.Cloud.SpannerLib.Native.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageId>Experimental.SpannerLib.Native</PackageId>
99
<Title>Experimental native library for Spanner</Title>
1010
<Authors />
11-
<Version>1.0.8</Version>
11+
<Version>1.0.9</Version>
1212
</PropertyGroup>
1313

1414
<ItemGroup>

spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Native/SpannerLib.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Google.Cloud.SpannerLib.Native
88
public static class SpannerLib
99
{
1010
private const string SpannerLibName = "spannerlib";
11+
//private const string SpannerLibName = "/Users/loite/CLionProjects/spannerlib/cmake-build-release/libspannerlib.dylib";
1112

1213
[DllImport(SpannerLibName, EntryPoint = "Release")]
1314
[DefaultDllImportSearchPaths(DllImportSearchPath.AssemblyDirectory)]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
# Clear all local nuget cache
3+
dotnet nuget locals --clear all
4+
dotnet pack
5+
dotnet nuget remove source local 2>/dev/null
6+
dotnet nuget add source "$PWD"/bin/Release --name local

spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib.Tests/BasicTests.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Diagnostics;
22
using Google.Cloud.Spanner.V1;
33
using Google.Cloud.SpannerLib.Tests.MockServer;
4+
using Google.Protobuf.WellKnownTypes;
45
using Grpc.Core;
56
using TypeCode = Google.Cloud.Spanner.V1.TypeCode;
67

@@ -10,7 +11,8 @@ public class BasicTests
1011
{
1112
private SpannerMockServerFixture _fixture;
1213

13-
private string ConnectionString => $"{_fixture.Host}:{_fixture.Port}/projects/p1/instances/i1/databases/d1;UsePlainText=true";
14+
// private string ConnectionString => $"{_fixture.Host}:{_fixture.Port}/projects/p1/instances/i1/databases/d1;UsePlainText=true";
15+
private string ConnectionString => $"projects/appdev-soda-spanner-staging/instances/knut-test-ycsb/databases/knut-test-db";
1416

1517
[SetUp]
1618
public void Setup()
@@ -54,6 +56,31 @@ public void TestExecuteQuery()
5456
}
5557
}
5658

59+
[Test]
60+
public void TestExecuteParameterizedQuery()
61+
{
62+
using var pool = Pool.Create(ConnectionString);
63+
using var connection = pool.CreateConnection();
64+
var parameters = new Struct
65+
{
66+
Fields =
67+
{
68+
["p1"] = Value.ForString("1")
69+
}
70+
};
71+
using var rows = connection.Execute(new ExecuteSqlRequest
72+
{
73+
Sql = "select col_varchar from all_types where col_bigint=$1::bigint",
74+
Params = parameters,
75+
});
76+
for (var row = rows.Next(); row != null; row = rows.Next())
77+
{
78+
Assert.That(row.Values.Count, Is.EqualTo(1));
79+
Assert.That(row.Values[0].HasStringValue);
80+
Assert.That(row.Values[0].StringValue, Is.EqualTo("1"));
81+
}
82+
}
83+
5784
[Test]
5885
[Ignore("execute async disabled for now")]
5986
public async Task TestExecuteQueryAsync()

spannerlib/dotnet-spannerlib/Google.Cloud.SpannerLib/Google.Cloud.SpannerLib.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Experimental.SpannerLib.Grpc" Version="1.0.2" />
16-
<PackageReference Include="Experimental.SpannerLib.Native" Version="1.0.7" />
16+
<PackageReference Include="Experimental.SpannerLib.Native" Version="1.0.9" />
1717
<PackageReference Include="Google.Cloud.Spanner.Admin.Database.V1" Version="5.1.0" />
1818
</ItemGroup>
1919

0 commit comments

Comments
 (0)