Skip to content

Commit 042b234

Browse files
authored
chore: Remove code smells and bump dependencies (#1374)
1 parent 136a966 commit 042b234

File tree

8 files changed

+31
-34
lines changed

8 files changed

+31
-34
lines changed

Directory.Packages.props

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.4.0"/>
7+
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.1"/>
88
<PackageVersion Include="Docker.DotNet.Enhanced.X509" Version="3.126.1"/>
99
<PackageVersion Include="Docker.DotNet.Enhanced" Version="3.126.1"/>
1010
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0"/>
1111
<PackageVersion Include="Microsoft.Bcl.HashCode" Version="1.1.1"/>
12-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2"/>
12+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.3"/>
1313
<PackageVersion Include="SharpZipLib" Version="1.4.2"/>
14-
<PackageVersion Include="SSH.NET" Version="2024.1.0"/>
14+
<PackageVersion Include="SSH.NET" Version="2024.2.0"/>
1515
<!-- Unit and integration test dependencies: -->
1616
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
1717
<PackageVersion Include="Microsoft.Extensions.Diagnostics.Testing" Version="8.10.0"/>
18-
<PackageVersion Include="coverlet.collector" Version="6.0.2"/>
19-
<PackageVersion Include="Dapper" Version="2.1.35"/>
18+
<PackageVersion Include="coverlet.collector" Version="6.0.4"/>
19+
<PackageVersion Include="Dapper" Version="2.1.66"/>
2020
<PackageVersion Include="ReflectionMagic" Version="5.0.1"/>
21-
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.0"/>
22-
<PackageVersion Include="xunit" Version="2.9.2"/>
21+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.0.2"/>
22+
<PackageVersion Include="xunit" Version="2.9.3"/>
2323
<!-- xUnit.net extensibility for Testcontainers.Xunit and Testcontainers.XunitV3 packages: -->
24-
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.0"/>
24+
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.3"/>
2525
<PackageVersion Include="xunit.v3.extensibility.core" Version="1.1.0"/>
2626
<!-- Third-party client dependencies to connect and interact with the containers: -->
2727
<PackageVersion Include="Apache.NMS.ActiveMQ" Version="2.1.0"/>
@@ -46,7 +46,7 @@
4646
<PackageVersion Include="Net.IBM.Data.Db2-lnx" Version="9.0.0.100"/>
4747
<PackageVersion Include="Net.IBM.Data.Db2-osx" Version="9.0.0.100"/>
4848
<PackageVersion Include="Net.IBM.Data.Db2" Version="9.0.0.100"/>
49-
<PackageVersion Include="DotPulsar" Version="3.3.2"/>
49+
<PackageVersion Include="DotPulsar" Version="3.6.0"/>
5050
<PackageVersion Include="Elastic.Clients.Elasticsearch" Version="8.16.3"/>
5151
<PackageVersion Include="EventStore.Client.Grpc.Streams" Version="22.0.0"/>
5252
<PackageVersion Include="FirebirdSql.Data.FirebirdClient" Version="10.0.0"/>

docs/modules/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ await moduleNameContainer.StartAsync();
3535
| Consul | `consul:1.15` | [NuGet](https://www.nuget.org/packages/Testcontainers.Consul) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Consul) |
3636
| 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) |
3737
| CouchDB | `couchdb:3.3` | [NuGet](https://www.nuget.org/packages/Testcontainers.CouchDb) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.CouchDb) |
38+
| 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) |
3839
| 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) |
3940
| 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) |
4041
| 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) |
@@ -64,7 +65,9 @@ await moduleNameContainer.StartAsync();
6465
| 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) |
6566
| Redis | `redis:7.0` | [NuGet](https://www.nuget.org/packages/Testcontainers.Redis) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Redis) |
6667
| 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) |
68+
| Sftp | `atmoz/sftp:alpine` | [NuGet](https://www.nuget.org/packages/Testcontainers.Sftp) | [Source](https://github.com/testcontainers/testcontainers-dotnet/tree/develop/src/Testcontainers.Sftp) |
6769
| 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) |
70+
| 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) |
6871
| 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) |
6972

7073
## Implement a module

src/Testcontainers.EventHubs/EventHubsBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public override EventHubsContainer Build()
115115
.WithNetworkAliases(AzuriteNetworkAlias)
116116
.Build();
117117

118-
var eventHubsContainer = WithAzuriteContainer(network, container, AzuriteNetworkAlias);
119-
return new EventHubsContainer(eventHubsContainer.DockerResourceConfiguration);
118+
var eventHubsBuilder = WithAzuriteContainer(network, container, AzuriteNetworkAlias);
119+
return new EventHubsContainer(eventHubsBuilder.DockerResourceConfiguration);
120120
}
121121

122122
/// <inheritdoc />

src/Testcontainers.EventHubs/EventHubsContainer.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ namespace Testcontainers.EventHubs;
44
[PublicAPI]
55
public sealed class EventHubsContainer : DockerContainer
66
{
7-
private readonly EventHubsConfiguration _configuration;
8-
97
/// <summary>
108
/// Initializes a new instance of the <see cref="EventHubsContainer" /> class.
119
/// </summary>
1210
/// <param name="configuration">The container configuration.</param>
1311
public EventHubsContainer(EventHubsConfiguration configuration)
1412
: base(configuration)
1513
{
16-
_configuration = configuration;
1714
}
1815

1916
/// <summary>

src/Testcontainers.ServiceBus/ServiceBusBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public override ServiceBusContainer Build()
105105
.WithNetworkAliases(DatabaseNetworkAlias)
106106
.Build();
107107

108-
var serviceBusContainer = WithMsSqlContainer(network, container, DatabaseNetworkAlias);
109-
return new ServiceBusContainer(serviceBusContainer.DockerResourceConfiguration);
108+
var serviceBusBuilder = WithMsSqlContainer(network, container, DatabaseNetworkAlias);
109+
return new ServiceBusContainer(serviceBusBuilder.DockerResourceConfiguration);
110110
}
111111

112112
/// <inheritdoc />

src/Testcontainers.Sftp/SftpBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ public override SftpContainer Build()
7171
{
7272
Validate();
7373

74-
var sftpContainer = WithCommand(string.Join(
74+
var sftpBuilder = WithCommand(string.Join(
7575
":",
7676
DockerResourceConfiguration.Username,
7777
DockerResourceConfiguration.Password,
7878
string.Empty,
7979
string.Empty,
8080
DockerResourceConfiguration.UploadDirectory));
8181

82-
return new SftpContainer(sftpContainer.DockerResourceConfiguration);
82+
return new SftpContainer(sftpBuilder.DockerResourceConfiguration);
8383
}
8484

8585
/// <inheritdoc />

tests/Testcontainers.Pulsar.Tests/PulsarContainerTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public async Task ConsumerReceivesSendMessage()
4141
_ = clientBuilder.Authentication(new TokenAuthentication(authToken));
4242
}
4343

44-
var client = clientBuilder.Build();
44+
await using var client = clientBuilder.Build();
4545

4646
await using var producer = client.NewProducer(Schema.String)
4747
.Topic(topic)
@@ -50,7 +50,6 @@ public async Task ConsumerReceivesSendMessage()
5050
await using var consumer = client.NewConsumer(Schema.String)
5151
.Topic(topic)
5252
.SubscriptionName(name)
53-
.InitialPosition(SubscriptionInitialPosition.Earliest)
5453
.Create();
5554

5655
// When

tests/Testcontainers.Tests/ContinuousIntegration/JobsTest.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ namespace DotNet.Testcontainers.Tests.ContinuousIntegration
22
{
33
using System.IO;
44
using System.Linq;
5-
using System.Runtime.CompilerServices;
65
using System.Text.RegularExpressions;
6+
using DotNet.Testcontainers.Builders;
77
using Xunit;
88

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

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

24-
var missingConfiguredProjects = existingProjects.Except(configuredProjects).ToList();
25-
if (missingConfiguredProjects.Count > 0)
26-
{
27-
Assert.Fail($"{string.Join(", ", missingConfiguredProjects)} must be configured in {ciCdFilePath}");
28-
}
22+
var actualProjects = Directory.GetFiles(GetTestsDirectoryPath(), "*.Tests.csproj", SearchOption.AllDirectories).Select(name => Path.GetFileName(name)[..^13]).ToList();
23+
Assert.NotEmpty(actualProjects);
24+
25+
var missingConfiguredProjects = actualProjects.Except(expectedProjects).ToList();
26+
Assert.True(missingConfiguredProjects.Count == 0, $"{string.Join(", ", missingConfiguredProjects)} must be configured in '{ciCdFilePath}'.");
2927
}
3028

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

33-
private static string GetTestsPath() => Path.Combine(GetRepositoryPath(), "tests");
31+
private static string GetTestsDirectoryPath() => Path.Combine(GetRepositoryDirectoryPath(), "tests");
3432

35-
private static string GetRepositoryPath([CallerFilePath] string path = "") => Path.GetFullPath(Path.Combine(Path.GetDirectoryName(path)!, "..", "..", ".."));
33+
private static string GetRepositoryDirectoryPath() => CommonDirectoryPath.GetSolutionDirectory().DirectoryPath;
3634
}
3735
}

0 commit comments

Comments
 (0)