-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
Feature/455 Added WithNetworkAliases functionality #480
Feature/455 Added WithNetworkAliases functionality #480
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. I can do the review in the next days. Today I’m busy.
1592305
to
3831a37
Compare
src/Testcontainers/Clients/TestcontainersConfigurationConverter.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Clients/TestcontainersConfigurationConverter.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably I expressed myself unclear. What I meant is, that you can use a similar or the same approach to test your changes, like TestcontainersNetworkTest
and NetworkFixture
does.
You can revert the changes in TestcontainersNetworkTest
and NetworkFixture
and replace it with something like:
diff --git a/tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs b/tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs
index 01a0e26..b5cb7aa 100644
--- a/tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs
+++ b/tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs
@@ -9,6 +9,8 @@ namespace DotNet.Testcontainers.Tests.Unit
[Collection(nameof(Testcontainers))]
public sealed class TestcontainersNetworkTest : IClassFixture<NetworkFixture>, IAsyncLifetime
{
+ private const string Alias = "-alias";
+
private readonly ITestcontainersContainer testcontainer1;
private readonly ITestcontainersContainer testcontainer2;
@@ -22,10 +24,12 @@ namespace DotNet.Testcontainers.Tests.Unit
this.testcontainer1 = testcontainersBuilder
.WithHostname(nameof(this.testcontainer1))
+ .WithNetworkAliases(nameof(this.testcontainer1) + Alias)
.Build();
this.testcontainer2 = testcontainersBuilder
.WithHostname(nameof(this.testcontainer2))
+ .WithNetworkAliases(nameof(this.testcontainer2) + Alias)
.Build();
}
@@ -39,10 +43,14 @@ namespace DotNet.Testcontainers.Tests.Unit
return Task.WhenAll(this.testcontainer1.DisposeAsync().AsTask(), this.testcontainer2.DisposeAsync().AsTask());
}
- [Fact]
- public async Task PingContainer()
+ [Theory]
+ [InlineData(nameof(testcontainer2))]
+ [InlineData(nameof(testcontainer2) + Alias)]
+ public async Task Ping(string destination)
{
- Assert.Equal(0, (await this.testcontainer1.ExecAsync(new[] { "ping", "-c", "4", nameof(this.testcontainer2) })).ExitCode);
+ var execResult = await this.testcontainer1.ExecAsync(new[] { "ping", "-c", "4", destination })
+ .ConfigureAwait(false);
+ Assert.Equal(0, execResult.ExitCode);
}
}
}
If you know how it works, it would be nice if you squash your commits to a single commit.
tests/Testcontainers.Tests/Unit/Networks/TestcontainersNetworkTest.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/TestcontainersContainerTest.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Clients/TestcontainersConfigurationConverter.cs
Outdated
Show resolved
Hide resolved
0a4072c
to
80637b9
Compare
Updated - nice design |
Squashed as you wanted |
80637b9
to
ccb3976
Compare
Published in |
This PR should bring new functionality
WithNetworkAliases
toITestcontainersBuilder<>