Created
April 25, 2026 23:11
-
-
Save NixonInnes/d43b892dd1673a1523bf5d79ec3f7335 to your computer and use it in GitHub Desktop.
SurrealDb.Net Bug Repro - Cbor empty typeString
This file contains hidden or 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
| #!/usr/bin/env dotnet | |
| #:property PublishAot=false | |
| #:package SurrealDb.Net@0.9.0 | |
| #:package Testcontainers@4.5.0 | |
| using SurrealDb.Net; | |
| using SurrealDb.Net.Models.Auth; | |
| using DotNet.Testcontainers.Builders; | |
| using DotNet.Testcontainers.Containers; | |
| await using var fixture = new SurrealDbFixture(); | |
| await fixture.InitializeAsync(); | |
| var client = await fixture.CreateClientAsync("test_ns", "test_db"); | |
| var resp = await client.RawQuery("RETURN 1;"); | |
| public sealed class SurrealDbFixture : IAsyncDisposable | |
| { | |
| private const ushort SurrealDbPort = 8000; | |
| private const string RootUser = "root"; | |
| private const string RootPassword = "root"; | |
| private readonly IContainer _container = new ContainerBuilder() | |
| .WithImage("surrealdb/surrealdb:latest") | |
| .WithPortBinding(SurrealDbPort, true) | |
| .WithCommand("start", "--user", RootUser, "--pass", RootPassword, "memory") | |
| .WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Started web server")) | |
| .Build(); | |
| public string Endpoint => $"ws://{_container.Hostname}:{_container.GetMappedPublicPort(SurrealDbPort)}/rpc"; | |
| public async Task InitializeAsync() | |
| { | |
| await _container.StartAsync(); | |
| await WaitForReadinessAsync(); | |
| } | |
| public async ValueTask DisposeAsync() | |
| { | |
| await _container.DisposeAsync(); | |
| } | |
| public async Task<SurrealDbClient> CreateClientAsync( | |
| string ns, | |
| string db, | |
| CancellationToken cancellationToken = default) | |
| { | |
| var client = new SurrealDbClient(Endpoint); | |
| await client.SignIn(new RootAuth | |
| { | |
| Username = RootUser, | |
| Password = RootPassword | |
| }, cancellationToken); | |
| await client.Use(ns, db, cancellationToken); | |
| return client; | |
| } | |
| private async Task WaitForReadinessAsync() | |
| { | |
| for (var attempt = 0; attempt < 20; attempt++) | |
| { | |
| try | |
| { | |
| await using var client = new SurrealDbClient(Endpoint); | |
| await client.SignIn(new RootAuth | |
| { | |
| Username = RootUser, | |
| Password = RootPassword | |
| }); | |
| return; | |
| } | |
| catch | |
| { | |
| await Task.Delay(500); | |
| } | |
| } | |
| throw new InvalidOperationException("SurrealDB container did not become ready in time."); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment