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

Pin the version from Testcontainers to 3.7.0 in WireMock.Net.Testcontainers #1057

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,12 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Stef.Validation" Version="0.1.1" />
<PackageReference Include="Testcontainers" Version="3.6.0" />
<PackageReference Include="Testcontainers" Version="[3.7.0]" />
<PackageReference Include="JetBrains.Annotations" VersionOverride="2022.3.1" PrivateAssets="All" Version="2023.3.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Http\" />
</ItemGroup>

</Project>
5 changes: 1 addition & 4 deletions src/WireMock.Net.Testcontainers/WireMockConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ public sealed class WireMockConfiguration : ContainerConfiguration

public bool HasBasicAuthentication => !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password);

public WireMockConfiguration(
string? username = null,
string? password = null
)
public WireMockConfiguration(string? username = null, string? password = null)
{
Username = username;
Password = password;
Expand Down
5 changes: 5 additions & 0 deletions src/WireMock.Net.Testcontainers/WireMockContainerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public sealed class WireMockContainerBuilder : ContainerBuilder<WireMockContaine

private readonly Lazy<Task<bool>> _isWindowsAsLazy = new(async () =>
{
if (TestcontainersSettings.OS.DockerEndpointAuthConfig == null)
{
throw new InvalidOperationException($"The {nameof(TestcontainersSettings.OS.DockerEndpointAuthConfig)} is null. Check if Docker is started.");
}

using var dockerClientConfig = TestcontainersSettings.OS.DockerEndpointAuthConfig.GetDockerClientConfiguration();
using var dockerClient = dockerClientConfig.CreateClient();

Expand Down
43 changes: 43 additions & 0 deletions test/WireMock.Net.Tests/Testcontainers/TestcontainersTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#if NET6_0_OR_GREATER
using System.Threading.Tasks;
using FluentAssertions;
using FluentAssertions.Execution;
using WireMock.Net.Testcontainers;
using Xunit;

namespace WireMock.Net.Tests.Testcontainers;

public class TestcontainersTests
{
[Fact]
public async Task WireMockContainer_Build_and_StartAsync_and_StopAsync()
{
// Act
var wireMockContainer = new WireMockContainerBuilder()
.WithAutoRemove(true)
.WithCleanUp(true)
.Build();

try
{
await wireMockContainer.StartAsync().ConfigureAwait(false);

// Assert
using (new AssertionScope())
{
var url = wireMockContainer.GetPublicUrl();
url.Should().NotBeNullOrWhiteSpace();

var adminClient = wireMockContainer.CreateWireMockAdminClient();

var settings = await adminClient.GetSettingsAsync();
settings.Should().NotBeNull();
}
}
finally
{
await wireMockContainer.StopAsync();
}
}
}
#endif
4 changes: 4 additions & 0 deletions test/WireMock.Net.Tests/WireMock.Net.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.4.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0'">
<ProjectReference Include="..\..\src\WireMock.Net.Testcontainers\WireMock.Net.Testcontainers.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="OpenApiParser\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
Loading