Skip to content

Commit 57c4249

Browse files
authored
Pin the version from Testcontainers to 3.7.0 in WireMock.Net.Testcontainers (#1057)
* TestcontainersTests * WireMockContainer_Build_and_StartAsync_and_StopAsync * -- * [3.7.0]
1 parent 057cd6c commit 57c4249

File tree

5 files changed

+55
-9
lines changed

5 files changed

+55
-9
lines changed

src/WireMock.Net.Testcontainers/WireMock.Net.Testcontainers.csproj

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,12 @@
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
</PackageReference>
3131
<PackageReference Include="Stef.Validation" Version="0.1.1" />
32-
<PackageReference Include="Testcontainers" Version="3.6.0" />
32+
<PackageReference Include="Testcontainers" Version="[3.7.0]" />
3333
<PackageReference Include="JetBrains.Annotations" VersionOverride="2022.3.1" PrivateAssets="All" Version="2023.3.0" />
3434
</ItemGroup>
3535

3636
<ItemGroup>
3737
<ProjectReference Include="..\WireMock.Net.RestClient\WireMock.Net.RestClient.csproj" />
3838
</ItemGroup>
39-
40-
<ItemGroup>
41-
<Folder Include="Http\" />
42-
</ItemGroup>
39+
4340
</Project>

src/WireMock.Net.Testcontainers/WireMockConfiguration.cs

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ public sealed class WireMockConfiguration : ContainerConfiguration
1616

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

19-
public WireMockConfiguration(
20-
string? username = null,
21-
string? password = null
22-
)
19+
public WireMockConfiguration(string? username = null, string? password = null)
2320
{
2421
Username = username;
2522
Password = password;

src/WireMock.Net.Testcontainers/WireMockContainerBuilder.cs

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public sealed class WireMockContainerBuilder : ContainerBuilder<WireMockContaine
2525

2626
private readonly Lazy<Task<bool>> _isWindowsAsLazy = new(async () =>
2727
{
28+
if (TestcontainersSettings.OS.DockerEndpointAuthConfig == null)
29+
{
30+
throw new InvalidOperationException($"The {nameof(TestcontainersSettings.OS.DockerEndpointAuthConfig)} is null. Check if Docker is started.");
31+
}
32+
2833
using var dockerClientConfig = TestcontainersSettings.OS.DockerEndpointAuthConfig.GetDockerClientConfiguration();
2934
using var dockerClient = dockerClientConfig.CreateClient();
3035

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#if NET6_0_OR_GREATER
2+
using System.Threading.Tasks;
3+
using FluentAssertions;
4+
using FluentAssertions.Execution;
5+
using WireMock.Net.Testcontainers;
6+
using Xunit;
7+
8+
namespace WireMock.Net.Tests.Testcontainers;
9+
10+
public class TestcontainersTests
11+
{
12+
[Fact]
13+
public async Task WireMockContainer_Build_and_StartAsync_and_StopAsync()
14+
{
15+
// Act
16+
var wireMockContainer = new WireMockContainerBuilder()
17+
.WithAutoRemove(true)
18+
.WithCleanUp(true)
19+
.Build();
20+
21+
try
22+
{
23+
await wireMockContainer.StartAsync().ConfigureAwait(false);
24+
25+
// Assert
26+
using (new AssertionScope())
27+
{
28+
var url = wireMockContainer.GetPublicUrl();
29+
url.Should().NotBeNullOrWhiteSpace();
30+
31+
var adminClient = wireMockContainer.CreateWireMockAdminClient();
32+
33+
var settings = await adminClient.GetSettingsAsync();
34+
settings.Should().NotBeNull();
35+
}
36+
}
37+
finally
38+
{
39+
await wireMockContainer.StopAsync();
40+
}
41+
}
42+
}
43+
#endif

test/WireMock.Net.Tests/WireMock.Net.Tests.csproj

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
<PackageReference Include="JsonConverter.System.Text.Json" Version="0.4.0" />
106106
</ItemGroup>
107107

108+
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' or '$(TargetFramework)' == 'net7.0' or '$(TargetFramework)' == 'net8.0'">
109+
<ProjectReference Include="..\..\src\WireMock.Net.Testcontainers\WireMock.Net.Testcontainers.csproj" />
110+
</ItemGroup>
111+
108112
<ItemGroup>
109113
<None Update="OpenApiParser\*.json">
110114
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

0 commit comments

Comments
 (0)