Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create GarnetContainerTest.cs #1225

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions tests/Testcontainers.Redis.Tests/GarnetContainerTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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);
}
}
Loading