From e8d5c0eac7a90df24c111ed62ee9b9044274c3d2 Mon Sep 17 00:00:00 2001 From: Meir Blachman Date: Mon, 5 Aug 2024 19:02:19 +0300 Subject: [PATCH 1/2] Create GarnetContainerTest.cs --- .../GarnetContainerTest.cs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs diff --git a/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs b/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs new file mode 100644 index 000000000..e2e56ed84 --- /dev/null +++ b/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs @@ -0,0 +1,43 @@ +namespace Testcontainers.Redis; +public sealed class GarnetContainerTest : IAsyncLifetime +{ + // see https://microsoft.github.io/garnet/docs/welcome/releases#docker + private readonly RedisContainer _garnetContainer = new RedisBuilder() + .WithImage("ghcr.io/microsoft/garnet") + .Build(); + + public Task InitializeAsync() + { + return _garnetContainer.StartAsync(); + } + + public Task DisposeAsync() + { + return _garnetContainer.DisposeAsync().AsTask(); + } + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public void ConnectionStateReturnsOpen() + { + using var connection = ConnectionMultiplexer.Connect(_garnetContainer.GetConnectionString()); + Assert.True(connection.IsConnected); + } + + [Fact] + [Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))] + public async Task ExecScriptReturnsSuccessful() + { + // Given + const string scriptContent = "return 'Hello, scripting!'"; + + // When + var execResult = await _garnetContainer.ExecScriptAsync(scriptContent) + .ConfigureAwait(true); + + // Then + Assert.True(0L.Equals(execResult.ExitCode), execResult.Stderr); + Assert.True("Hello, scripting!\n".Equals(execResult.Stdout), execResult.Stdout); + Assert.Empty(execResult.Stderr); + } +} From 2c11969427dbae13fbc7dc0ac558302f90240391 Mon Sep 17 00:00:00 2001 From: Meir Blachman Date: Mon, 5 Aug 2024 19:03:42 +0300 Subject: [PATCH 2/2] Update GarnetContainerTest.cs --- tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs b/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs index e2e56ed84..23f328595 100644 --- a/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs +++ b/tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs @@ -1,4 +1,5 @@ namespace Testcontainers.Redis; + public sealed class GarnetContainerTest : IAsyncLifetime { // see https://microsoft.github.io/garnet/docs/welcome/releases#docker