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

chore: Remove code smells and bump dependencies #1374

Merged
merged 1 commit into from
Feb 18, 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
18 changes: 9 additions & 9 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.4.0"/>
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.1"/>
<PackageVersion Include="Docker.DotNet.Enhanced.X509" Version="3.126.1"/>
<PackageVersion Include="Docker.DotNet.Enhanced" Version="3.126.1"/>
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0"/>
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2"/>
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3"/>
<PackageVersion Include="SharpZipLib" Version="1.4.2"/>
<PackageVersion Include="SSH.NET" Version="2024.1.0"/>
<PackageVersion Include="SSH.NET" Version="2024.2.0"/>
<!-- Unit and integration test dependencies: -->
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.10.0"/>
<PackageVersion Include="coverlet.collector" Version="6.0.2"/>
<PackageVersion Include="Dapper" Version="2.1.35"/>
<PackageVersion Include="coverlet.collector" Version="6.0.4"/>
<PackageVersion Include="Dapper" Version="2.1.66"/>
<PackageVersion Include="ReflectionMagic" Version="5.0.1"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0"/>
<PackageVersion Include="xunit" Version="2.9.2"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2"/>
<PackageVersion Include="xunit" Version="2.9.3"/>
<!-- xUnit.net extensibility for Testcontainers.Xunit and Testcontainers.XunitV3 packages: -->
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.0"/>
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.3"/>
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.1.0"/>
<!-- Third-party client dependencies to connect and interact with the containers: -->
<PackageVersion Include="Apache.NMS.ActiveMQ" Version="2.1.0"/>
Expand All @@ -45,7 +45,7 @@
<PackageVersion Include="Net.IBM.Data.Db2-lnx" Version="9.0.0.100"/>
<PackageVersion Include="Net.IBM.Data.Db2-osx" Version="9.0.0.100"/>
<PackageVersion Include="Net.IBM.Data.Db2" Version="9.0.0.100"/>
<PackageVersion Include="DotPulsar" Version="3.3.2"/>
<PackageVersion Include="DotPulsar" Version="3.6.0"/>
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="8.16.3"/>
<PackageVersion Include="EventStore.Client.Grpc.Streams" Version="22.0.0"/>
<PackageVersion Include="FirebirdSql.Data.FirebirdClient" Version="10.0.0"/>
Expand Down
3 changes: 3 additions & 0 deletions docs/modules/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ await moduleNameContainer.StartAsync();
| Consul | `consul:1.15` | [NuGet](https://www.nuget.org/packages/Testcontainers.Consul) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Consul) |
| Couchbase | `couchbase:community-7.0.2` | [NuGet](https://www.nuget.org/packages/Testcontainers.Couchbase) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Couchbase) |
| CouchDB | `couchdb:3.3` | [NuGet](https://www.nuget.org/packages/Testcontainers.CouchDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.CouchDb) |
| Db2 | `icr.io/db2_community/db2:12.1.0.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.Db2) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Db2) |
| DynamoDB | `amazon/dynamodb-local:1.21.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.DynamoDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.DynamoDb) |
| Elasticsearch | `elasticsearch:8.6.1` | [NuGet](https://www.nuget.org/packages/Testcontainers.Elasticsearch) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Elasticsearch) |
| EventStoreDB | `eventstore/eventstore:22.10.1-buster-slim` | [NuGet](https://www.nuget.org/packages/Testcontainers.EventStoreDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.EventStoreDb) |
Expand Down Expand Up @@ -63,7 +64,9 @@ await moduleNameContainer.StartAsync();
| RavenDB | `ravendb/ravendb:5.4-ubuntu-latest` | [NuGet](https://www.nuget.org/packages/Testcontainers.RavenDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.RavenDb) |
| Redis | `redis:7.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.Redis) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Redis) |
| Redpanda | `docker.redpanda.com/redpandadata/redpanda:v22.2.1` | [NuGet](https://www.nuget.org/packages/Testcontainers.Redpanda) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Redpanda) |
| Sftp | `atmoz/sftp:alpine` | [NuGet](https://www.nuget.org/packages/Testcontainers.Sftp) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Sftp) |
| SQL Server | `mcr.microsoft.com/mssql/server:2022-CU14-ubuntu-22.04` | [NuGet](https://www.nuget.org/packages/Testcontainers.MsSql) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.MsSql) |
| Weaviate | `semitechnologies/weaviate:1.26.14` | [NuGet](https://www.nuget.org/packages/Testcontainers.Weaviate) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Weaviate) |
| WebDriver | `selenium/standalone-chrome:110.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.WebDriver) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.WebDriver) |

## Implement a module
Expand Down
4 changes: 2 additions & 2 deletions src/Testcontainers.EventHubs/EventHubsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ public override EventHubsContainer Build()
.WithNetworkAliases(AzuriteNetworkAlias)
.Build();

var eventHubsContainer = WithAzuriteContainer(network, container, AzuriteNetworkAlias);
return new EventHubsContainer(eventHubsContainer.DockerResourceConfiguration);
var eventHubsBuilder = WithAzuriteContainer(network, container, AzuriteNetworkAlias);
return new EventHubsContainer(eventHubsBuilder.DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
3 changes: 0 additions & 3 deletions src/Testcontainers.EventHubs/EventHubsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ namespace Testcontainers.EventHubs;
[PublicAPI]
public sealed class EventHubsContainer : DockerContainer
{
private readonly EventHubsConfiguration _configuration;

/// <summary>
/// Initializes a new instance of the <see cref="EventHubsContainer" /> class.
/// </summary>
/// <param name="configuration">The container configuration.</param>
public EventHubsContainer(EventHubsConfiguration configuration)
: base(configuration)
{
_configuration = configuration;
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Testcontainers.ServiceBus/ServiceBusBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public override ServiceBusContainer Build()
.WithNetworkAliases(DatabaseNetworkAlias)
.Build();

var serviceBusContainer = WithMsSqlContainer(network, container, DatabaseNetworkAlias);
return new ServiceBusContainer(serviceBusContainer.DockerResourceConfiguration);
var serviceBusBuilder = WithMsSqlContainer(network, container, DatabaseNetworkAlias);
return new ServiceBusContainer(serviceBusBuilder.DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
4 changes: 2 additions & 2 deletions src/Testcontainers.Sftp/SftpBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public override SftpContainer Build()
{
Validate();

var sftpContainer = WithCommand(string.Join(
var sftpBuilder = WithCommand(string.Join(
":",
DockerResourceConfiguration.Username,
DockerResourceConfiguration.Password,
string.Empty,
string.Empty,
DockerResourceConfiguration.UploadDirectory));

return new SftpContainer(sftpContainer.DockerResourceConfiguration);
return new SftpContainer(sftpBuilder.DockerResourceConfiguration);
}

/// <inheritdoc />
Expand Down
3 changes: 1 addition & 2 deletions tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task ConsumerReceivesSendMessage()
_ = clientBuilder.Authentication(new TokenAuthentication(authToken));
}

var client = clientBuilder.Build();
await using var client = clientBuilder.Build();

await using var producer = client.NewProducer(Schema.String)
.Topic(topic)
Expand All @@ -50,7 +50,6 @@ public async Task ConsumerReceivesSendMessage()
await using var consumer = client.NewConsumer(Schema.String)
.Topic(topic)
.SubscriptionName(name)
.InitialPosition(SubscriptionInitialPosition.Earliest)
.Create();

// When
Expand Down
26 changes: 12 additions & 14 deletions tests/Testcontainers.Tests/ContinuousIntegration/JobsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ namespace DotNet.Testcontainers.Tests.ContinuousIntegration
{
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
using DotNet.Testcontainers.Builders;
using Xunit;

public partial class JobsTest
public sealed partial class JobsTest
{
[GeneratedRegex("name: \"(.+?)\"")]
private static partial Regex ProjectNameRegex();
Expand All @@ -15,23 +15,21 @@ public partial class JobsTest
public void AllTestProjectsShouldBeConfiguredForContinuousIntegration()
{
var ciCdFilePath = GetCiCdFilePath();
var configuredProjects = File.ReadAllLines(ciCdFilePath).Select(line => ProjectNameRegex().Match(line).Groups[1].Value).Where(line => line.Length > 0).ToList();
Assert.NotEmpty(configuredProjects);

var existingProjects = Directory.GetFiles(GetTestsPath(), "*.Tests.csproj", SearchOption.AllDirectories).Select(name => Path.GetFileName(name)[..^13]).ToList();
Assert.NotEmpty(existingProjects);
var expectedProjects = File.ReadAllLines(ciCdFilePath).Select(line => ProjectNameRegex().Match(line).Groups[1].Value).Where(line => line.Length > 0).ToList();
Assert.NotEmpty(expectedProjects);

var missingConfiguredProjects = existingProjects.Except(configuredProjects).ToList();
if (missingConfiguredProjects.Count > 0)
{
Assert.Fail($"{string.Join(", ", missingConfiguredProjects)} must be configured in {ciCdFilePath}");
}
var actualProjects = Directory.GetFiles(GetTestsDirectoryPath(), "*.Tests.csproj", SearchOption.AllDirectories).Select(name => Path.GetFileName(name)[..^13]).ToList();
Assert.NotEmpty(actualProjects);

var missingConfiguredProjects = actualProjects.Except(expectedProjects).ToList();
Assert.True(missingConfiguredProjects.Count == 0, $"{string.Join(", ", missingConfiguredProjects)} must be configured in '{ciCdFilePath}'.");
}

private static string GetCiCdFilePath() => Path.Combine(GetRepositoryPath(), ".github", "workflows", "cicd.yml");
private static string GetCiCdFilePath() => Path.Combine(GetRepositoryDirectoryPath(), ".github", "workflows", "cicd.yml");

private static string GetTestsPath() => Path.Combine(GetRepositoryPath(), "tests");
private static string GetTestsDirectoryPath() => Path.Combine(GetRepositoryDirectoryPath(), "tests");

private static string GetRepositoryPath([CallerFilePath] string path = "") => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path)!, "..", "..", ".."));
private static string GetRepositoryDirectoryPath() => CommonDirectoryPath.GetSolutionDirectory().DirectoryPath;
}
}
Loading