forked from testcontainers/testcontainers-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCockroachDbContainerTest.cs
More file actions
54 lines (44 loc) · 1.96 KB
/
Copy pathCockroachDbContainerTest.cs
File metadata and controls
54 lines (44 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
namespace Testcontainers.CockroachDb;
public abstract class CockroachDbContainerTest(CockroachDbContainerTest.CockroachDbFixture fixture)
{
[Fact]
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
public void ConnectionStateReturnsOpen()
{
// Given
using DbConnection connection = fixture.CreateConnection();
// When
connection.Open();
// Then
Assert.Equal(ConnectionState.Open, connection.State);
}
[Fact]
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
public async Task ExecScriptReturnsSuccessful()
{
// Given
const string scriptContent = "SELECT 1;";
// When
var execResult = await fixture.Container.ExecScriptAsync(scriptContent)
.ConfigureAwait(true);
// Then
Assert.True(0L.Equals(execResult.ExitCode), execResult.Stderr);
Assert.Empty(execResult.Stderr);
}
[UsedImplicitly]
public sealed class CockroachDbContainerDefaultConfiguration(CockroachDbFixture fixture) : CockroachDbContainerTest(fixture), IClassFixture<CockroachDbFixture>;
[UsedImplicitly]
public sealed class CockroachDbContainerWaitForDatabase(CockroachDbFixtureWaitForDatabase fixture) : CockroachDbContainerTest(fixture), IClassFixture<CockroachDbFixtureWaitForDatabase>;
public class CockroachDbFixture(IMessageSink messageSink) : DbContainerFixture<CockroachDbBuilder, CockroachDbContainer>(messageSink)
{
public override DbProviderFactory DbProviderFactory => NpgsqlFactory.Instance;
}
[UsedImplicitly]
public sealed class CockroachDbFixtureWaitForDatabase(IMessageSink messageSink) : CockroachDbFixture(messageSink)
{
protected override CockroachDbBuilder Configure(CockroachDbBuilder builder)
{
return builder.WithWaitStrategy(Wait.ForUnixContainer().UntilDatabaseIsAvailable(DbProviderFactory));
}
}
}