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

Bump TestContainers from 3.8.0 to 4.1.0 #1201

Merged
merged 1 commit into from
Jan 30, 2025
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 @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.3"/>
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="TestContainers" Version="3.8.0"/>
<PackageReference Include="TestContainers" Version="4.1.0"/>
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.18" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="TestContainers" Version="3.8.0" />
<PackageReference Include="TestContainers" Version="4.1.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
using Docker.DotNet.Models;
using DotNet.Testcontainers;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Configurations;

namespace Motor.Extensions.Hosting.NATS_IntegrationTest;

public sealed class NATSBuilder : ContainerBuilder<NATSBuilder, NATSContainer, NATSConfiguration>
public sealed class NATSBuilder(NATSConfiguration resourceConfiguration)
: ContainerBuilder<NATSBuilder, NATSContainer, NATSConfiguration>(resourceConfiguration)
{
public const string DefaultImage = "nats:2.9.11";
public const int DefaultPort = 4222;

protected override NATSConfiguration DockerResourceConfiguration { get; }
protected override NATSConfiguration DockerResourceConfiguration { get; } = resourceConfiguration;

public NATSBuilder() : this(new NATSConfiguration())
{
DockerResourceConfiguration = Init().DockerResourceConfiguration;
}

public NATSBuilder(NATSConfiguration resourceConfiguration) : base(resourceConfiguration)
{
DockerResourceConfiguration = resourceConfiguration;
}

public override NATSContainer Build()
{
Validate();
return new NATSContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new NATSContainer(DockerResourceConfiguration);
}

protected override NATSBuilder Init()
{
return base.Init()
.WithImage(DefaultImage)
.WithLogger(ConsoleLogger.Instance)
.WithPortBinding(DefaultPort, true)
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Server is ready"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@

namespace Motor.Extensions.Hosting.NATS_IntegrationTest;

public class NATSContainer : DockerContainer
{
public NATSContainer(IContainerConfiguration configuration, ILogger logger) : base(configuration, logger)
{
}
}
public class NATSContainer(IContainerConfiguration configuration) : DockerContainer(configuration);
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.18" />
<PackageReference Include="TestContainers" Version="3.8.0" />
<PackageReference Include="TestContainers" Version="4.1.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
14 changes: 6 additions & 8 deletions test/Motor.Extensions.Hosting.SQS_IntegrationTest/SQSBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
using System.Collections.Generic;
using Docker.DotNet.Models;
using DotNet.Testcontainers;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Configurations;

namespace Motor.Extensions.Hosting.SQS_IntegrationTest;

public sealed class SQSBuilder : ContainerBuilder<SQSBuilder, SQSContainer, SQSConfiguration>
public sealed class SQSBuilder(SQSConfiguration resourceConfiguration)
: ContainerBuilder<SQSBuilder, SQSContainer, SQSConfiguration>(resourceConfiguration)
{
public const string DefaultImage = "roribio16/alpine-sqs:1.2.0";
public const int DefaultPort = 9324;

protected override SQSConfiguration DockerResourceConfiguration { get; }
protected override SQSConfiguration DockerResourceConfiguration { get; } = resourceConfiguration;

public SQSBuilder() : this(new SQSConfiguration())
{
DockerResourceConfiguration = Init().DockerResourceConfiguration;
}

public SQSBuilder(SQSConfiguration resourceConfiguration) : base(resourceConfiguration)
{
DockerResourceConfiguration = resourceConfiguration;
}

public override SQSContainer Build()
{
Validate();
return new SQSContainer(DockerResourceConfiguration, TestcontainersSettings.Logger);
return new SQSContainer(DockerResourceConfiguration);
}

protected override SQSBuilder Init()
{
var ulimit = new Ulimit { Name = "nofile", Soft = 1024, Hard = 1024 };
return base.Init()
.WithImage(DefaultImage)
.WithLogger(ConsoleLogger.Instance)
.WithPortBinding(DefaultPort, true)
.WithCreateParameterModifier(g => g.HostConfig.Ulimits = new List<Ulimit> { ulimit })
.WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("listening on port"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@

namespace Motor.Extensions.Hosting.SQS_IntegrationTest;

public class SQSContainer : DockerContainer
public class SQSContainer(IContainerConfiguration configuration) : DockerContainer(configuration)
{

public SQSContainer(IContainerConfiguration configuration, ILogger logger) : base(configuration, logger)
{
}

public string BaseSQSUrl => new UriBuilder("http", Hostname, GetMappedPublicPort(SQSBuilder.DefaultPort)).ToString();
}
Loading