Skip to content

Commit 6e27af6

Browse files
chore: Set remaining container image explicit (#1606)
Co-authored-by: Andre Hofmeister <[email protected]>
1 parent 2218693 commit 6e27af6

File tree

13 files changed

+58
-24
lines changed

13 files changed

+58
-24
lines changed

src/Testcontainers.EventHubs/EventHubsBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public override EventHubsContainer Build()
142142
var network = new NetworkBuilder()
143143
.Build();
144144

145-
var container = new AzuriteBuilder()
145+
var container = new AzuriteBuilder("mcr.microsoft.com/azure-storage/azurite:3.28.0")
146146
.WithNetwork(network)
147147
.WithNetworkAliases(AzuriteNetworkAlias)
148148
.Build();

src/Testcontainers.ServiceBus/ServiceBusBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public override ServiceBusContainer Build()
147147
var network = new NetworkBuilder()
148148
.Build();
149149

150-
var container = new MsSqlBuilder()
150+
var container = new MsSqlBuilder("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04")
151151
.WithNetwork(network)
152152
.WithNetworkAliases(DatabaseNetworkAlias)
153153
.Build();

src/Testcontainers/Containers/SocatBuilder.cs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,54 @@ namespace DotNet.Testcontainers.Containers
66
using Docker.DotNet.Models;
77
using DotNet.Testcontainers.Builders;
88
using DotNet.Testcontainers.Configurations;
9+
using DotNet.Testcontainers.Images;
910
using JetBrains.Annotations;
1011

1112
/// <inheritdoc cref="ContainerBuilder{TBuilderEntity, TContainerEntity, TConfigurationEntity}" />
1213
[PublicAPI]
1314
public sealed class SocatBuilder : ContainerBuilder<SocatBuilder, SocatContainer, SocatConfiguration>
1415
{
15-
public const string SocatImage = "alpine/socat:1.7.4.3-r0";
16+
[Obsolete("This constant is obsolete and will be removed in the future. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.")]
17+
public const string SocatImage = "alpine/socat:1.7.4.4";
1618

1719
/// <summary>
1820
/// Initializes a new instance of the <see cref="SocatBuilder" /> class.
1921
/// </summary>
22+
[Obsolete("This parameterless constructor is obsolete and will be removed. Use the constructor with the image parameter instead: https://github.com/testcontainers/testcontainers-dotnet/discussions/1470#discussioncomment-15185721.")]
2023
public SocatBuilder()
21-
: this(new SocatConfiguration())
24+
: this(SocatImage)
2225
{
23-
DockerResourceConfiguration = Init().DockerResourceConfiguration;
26+
}
27+
28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="SocatBuilder" /> class.
30+
/// </summary>
31+
/// <param name="image">
32+
/// The full Docker image name, including the image repository and tag
33+
/// (e.g., <c>alpine/socat:1.7.4.4</c>).
34+
/// </param>
35+
/// <remarks>
36+
/// Docker image tags available at <see href="https://hub.docker.com/r/alpine/socat/tags" />.
37+
/// </remarks>
38+
public SocatBuilder(string image)
39+
: this(new DockerImage(image))
40+
{
41+
}
42+
43+
/// <summary>
44+
/// Initializes a new instance of the <see cref="SocatBuilder" /> class.
45+
/// </summary>
46+
/// <param name="image">
47+
/// An <see cref="IImage" /> instance that specifies the Docker image to be used
48+
/// for the container builder configuration.
49+
/// </param>
50+
/// <remarks>
51+
/// Docker image tags available at <see href="https://hub.docker.com/r/alpine/socat/tags" />.
52+
/// </remarks>
53+
public SocatBuilder(IImage image)
54+
: this(new SocatConfiguration())
55+
{
56+
DockerResourceConfiguration = Init().WithImage(image).DockerResourceConfiguration;
2457
}
2558

2659
/// <summary>

tests/Testcontainers.EventHubs.Tests/EventHubsContainerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public DatabaseFixture()
108108
Network = new NetworkBuilder()
109109
.Build();
110110

111-
Container = new AzuriteBuilder()
111+
Container = new AzuriteBuilder("mcr.microsoft.com/azure-storage/azurite:3.28.0")
112112
.WithNetwork(Network)
113113
.WithNetworkAliases(AzuriteNetworkAlias)
114114
.Build();

tests/Testcontainers.Platform.Linux.Tests/ConnectionStringProviderTest.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ public sealed class Configured : IAsyncLifetime
1212

1313
public Configured()
1414
{
15-
_container = new ContainerBuilder()
16-
.WithImage(CommonImages.Alpine)
15+
_container = new ContainerBuilder(CommonImages.Alpine)
1716
.WithCommand(CommonCommands.SleepInfinity)
1817
.WithConnectionStringProvider(_connectionStringProvider)
1918
.Build();
@@ -42,8 +41,7 @@ public void GetConnectionStringReturnsExpectedValue()
4241

4342
public sealed class NotConfigured : IAsyncLifetime
4443
{
45-
private readonly IContainer _container = new ContainerBuilder()
46-
.WithImage(CommonImages.Alpine)
44+
private readonly IContainer _container = new ContainerBuilder(CommonImages.Alpine)
4745
.WithCommand(CommonCommands.SleepInfinity)
4846
.Build();
4947

tests/Testcontainers.Platform.Linux.Tests/SocatContainerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public SocatContainerTest()
2020
.WithNetworkAliases(HelloWorldAlias)
2121
.Build();
2222

23-
_socatContainer = new SocatBuilder()
23+
_socatContainer = new SocatBuilder(CommonImages.Socat)
2424
.WithNetwork(_network)
2525
.WithTarget(8080, HelloWorldAlias)
2626
.WithTarget(8081, HelloWorldAlias, 8080)

tests/Testcontainers.ServiceBus.Tests/DeclineLicenseAgreementTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ public sealed partial class DeclineLicenseAgreementTest
99
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
1010
public void WithoutAcceptingLicenseAgreementThrowsArgumentException()
1111
{
12-
var exception = Assert.Throws<ArgumentException>(() => new ServiceBusBuilder().Build());
12+
var exception = Assert.Throws<ArgumentException>(() => new ServiceBusBuilder(TestSession.GetImageFromDockerfile()).Build());
1313
Assert.Matches(LicenseAgreementNotAccepted(), exception.Message);
1414
}
1515

1616
[Fact]
1717
[Trait(nameof(DockerCli.DockerPlatform), nameof(DockerCli.DockerPlatform.Linux))]
1818
public void WithLicenseAgreementDeclinedThrowsArgumentException()
1919
{
20-
var exception = Assert.Throws<ArgumentException>(() => new ServiceBusBuilder().WithAcceptLicenseAgreement(false).Build());
20+
var exception = Assert.Throws<ArgumentException>(() => new ServiceBusBuilder(TestSession.GetImageFromDockerfile()).WithAcceptLicenseAgreement(false).Build());
2121
Assert.Matches(LicenseAgreementNotAccepted(), exception.Message);
2222
}
2323
}

tests/Testcontainers.ServiceBus.Tests/ServiceBusContainerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public DatabaseFixture()
116116
Network = new NetworkBuilder()
117117
.Build();
118118

119-
Container = new MsSqlBuilder()
119+
Container = new MsSqlBuilder("mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04")
120120
.WithNetwork(Network)
121121
.WithNetworkAliases(DatabaseNetworkAlias)
122122
.Build();

tests/Testcontainers.Tests/Fixtures/Containers/Unix/DockerMTls.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ namespace DotNet.Testcontainers.Tests.Fixtures
22
{
33
using System.Collections.Generic;
44
using DotNet.Testcontainers.Builders;
5+
using DotNet.Testcontainers.Images;
56

67
public abstract class DockerMTls : ProtectDockerDaemonSocket
78
{
89
public DockerMTls(string dockerImageVersion)
9-
: base(new ContainerBuilder(), dockerImageVersion)
10+
: base(new ContainerBuilder("docker:" + dockerImageVersion + "-dind"))
1011
{
1112
}
1213

tests/Testcontainers.Tests/Fixtures/Containers/Unix/DockerTlsFixture.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ namespace DotNet.Testcontainers.Tests.Fixtures
22
{
33
using System.Collections.Generic;
44
using DotNet.Testcontainers.Builders;
5+
using DotNet.Testcontainers.Images;
56
using JetBrains.Annotations;
67

78
[UsedImplicitly]
89
public sealed class DockerTlsFixture : ProtectDockerDaemonSocket
910
{
1011
public DockerTlsFixture()
11-
: base(new ContainerBuilder()
12-
.WithCommand("--tlsverify=false"), "29.0.0")
12+
: base(new ContainerBuilder("docker:29.0.0-dind")
13+
.WithCommand("--tlsverify=false"))
1314
{
1415
}
1516

0 commit comments

Comments
 (0)