From 1fe8d5666898e6dd2e48f9faf84ce1e638b1f7a4 Mon Sep 17 00:00:00 2001 From: Andre Hofmeister <9199345+HofmeisterAn@users.noreply.github.com> Date: Fri, 24 Feb 2023 21:45:48 +0100 Subject: [PATCH] chore!: Remove legacy TestcontainersNetworkBuilder, IDockerNetwork (#804) --- .../BackwardsCompatibility.cs | 32 ------------------- .../Builders/ContainerBuilder`3.cs | 5 --- .../Builders/IContainerBuilder`2.cs | 3 -- src/Testcontainers/Networks/DockerNetwork.cs | 2 +- src/Testcontainers/Networks/INetwork.cs | 20 ++---------- .../Testcontainers.Kafka.Tests.csproj | 2 +- .../Containers/Unix/NetworkFixture.cs | 4 +-- .../TestcontainersAccessInformationTest.cs | 2 +- .../TestcontainerNetworkBuilderTest.cs | 8 ++--- 9 files changed, 11 insertions(+), 67 deletions(-) diff --git a/src/Testcontainers/BackwardCompatibility/BackwardsCompatibility.cs b/src/Testcontainers/BackwardCompatibility/BackwardsCompatibility.cs index 8e8fd8b37..213878b43 100644 --- a/src/Testcontainers/BackwardCompatibility/BackwardsCompatibility.cs +++ b/src/Testcontainers/BackwardCompatibility/BackwardsCompatibility.cs @@ -121,32 +121,6 @@ public DockerImage(IDockerImage image) } } - namespace Networks - { - [PublicAPI] - [Obsolete("Use the INetwork interface instead.")] - public interface IDockerNetwork - { - [NotNull] - string Name { get; } - - Task CreateAsync(CancellationToken ct = default); - - Task DeleteAsync(CancellationToken ct = default); - } - - /// - /// Maps the old to the new interface to provide backwards compatibility. - /// - internal sealed partial class DockerNetwork - { - public DockerNetwork(IDockerNetwork network) - { - this.network.Name = network.Name; - } - } - } - namespace Volumes { [PublicAPI] @@ -182,12 +156,6 @@ public sealed class TestcontainersBuilder : ContainerBuilder : I [Obsolete("Use WithImage(IImage) instead.")] TBuilderEntity WithImage(IDockerImage image); - [Obsolete("Use WithNetwork(INetwork) instead.")] - TBuilderEntity WithNetwork(IDockerNetwork network); - [Obsolete("Use WithVolumeMount(IVolume, string) instead.")] TBuilderEntity WithVolumeMount(IDockerVolume volume, string destination); diff --git a/src/Testcontainers/Networks/DockerNetwork.cs b/src/Testcontainers/Networks/DockerNetwork.cs index c4a26c056..e7f895e3c 100644 --- a/src/Testcontainers/Networks/DockerNetwork.cs +++ b/src/Testcontainers/Networks/DockerNetwork.cs @@ -10,7 +10,7 @@ namespace DotNet.Testcontainers.Networks /// [PublicAPI] - internal sealed partial class DockerNetwork : Resource, INetwork + internal sealed class DockerNetwork : Resource, INetwork { private readonly IDockerNetworkOperations dockerNetworkOperations; diff --git a/src/Testcontainers/Networks/INetwork.cs b/src/Testcontainers/Networks/INetwork.cs index 278c6f47c..05ef45a4e 100644 --- a/src/Testcontainers/Networks/INetwork.cs +++ b/src/Testcontainers/Networks/INetwork.cs @@ -1,35 +1,19 @@ namespace DotNet.Testcontainers.Networks { using System; - using System.Threading; - using System.Threading.Tasks; using JetBrains.Annotations; /// /// A network instance. /// [PublicAPI] - public interface INetwork : IDockerNetwork, IFutureResource + public interface INetwork : IFutureResource { /// /// Gets the name. /// /// Network has not been created. [NotNull] - new string Name { get; } - - /// - /// Creates the network. - /// - /// Cancellation token. - /// Task that completes when the network has been created. - new Task CreateAsync(CancellationToken ct = default); - - /// - /// Deletes the network. - /// - /// Cancellation token. - /// Task that completes when the network has been deleted. - new Task DeleteAsync(CancellationToken ct = default); + string Name { get; } } } diff --git a/tests/Testcontainers.Kafka.Tests/Testcontainers.Kafka.Tests.csproj b/tests/Testcontainers.Kafka.Tests/Testcontainers.Kafka.Tests.csproj index e3484db59..48b346772 100644 --- a/tests/Testcontainers.Kafka.Tests/Testcontainers.Kafka.Tests.csproj +++ b/tests/Testcontainers.Kafka.Tests/Testcontainers.Kafka.Tests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/Testcontainers.Tests/Fixtures/Containers/Unix/NetworkFixture.cs b/tests/Testcontainers.Tests/Fixtures/Containers/Unix/NetworkFixture.cs index 580ac5f16..6b0bbfab8 100644 --- a/tests/Testcontainers.Tests/Fixtures/Containers/Unix/NetworkFixture.cs +++ b/tests/Testcontainers.Tests/Fixtures/Containers/Unix/NetworkFixture.cs @@ -11,8 +11,8 @@ [UsedImplicitly] public sealed class NetworkFixture : IAsyncLifetime { - public IDockerNetwork Network { get; } - = new TestcontainersNetworkBuilder() + public INetwork Network { get; } + = new NetworkBuilder() .WithDriver(NetworkDriver.Bridge) .WithName(Guid.NewGuid().ToString("D")) .Build(); diff --git a/tests/Testcontainers.Tests/Unit/Configurations/TestcontainersAccessInformationTest.cs b/tests/Testcontainers.Tests/Unit/Configurations/TestcontainersAccessInformationTest.cs index 1150c2e15..1e27d08a5 100644 --- a/tests/Testcontainers.Tests/Unit/Configurations/TestcontainersAccessInformationTest.cs +++ b/tests/Testcontainers.Tests/Unit/Configurations/TestcontainersAccessInformationTest.cs @@ -114,7 +114,7 @@ public void QueryImageInformationOfNotCreatedImage() public void QueryNetworkInformationOfNotCreatedNetwork() { // Given - var networkBuilder = new TestcontainersNetworkBuilder() + var networkBuilder = new NetworkBuilder() .WithName(Guid.NewGuid().ToString("D")); // When diff --git a/tests/Testcontainers.Tests/Unit/Networks/TestcontainerNetworkBuilderTest.cs b/tests/Testcontainers.Tests/Unit/Networks/TestcontainerNetworkBuilderTest.cs index 2fd6d3b67..0b852d293 100644 --- a/tests/Testcontainers.Tests/Unit/Networks/TestcontainerNetworkBuilderTest.cs +++ b/tests/Testcontainers.Tests/Unit/Networks/TestcontainerNetworkBuilderTest.cs @@ -23,7 +23,7 @@ public sealed class TestcontainerNetworkBuilderTest : IClassFixture ParameterModifier = new KeyValuePair(TestcontainersClient.TestcontainersLabel + ".parameter.modifier", Guid.NewGuid().ToString("D")); - private readonly IDockerNetwork network; + private readonly INetwork network; public TestcontainerNetworkBuilderTest(DockerNetwork network) { @@ -33,7 +33,7 @@ public TestcontainerNetworkBuilderTest(DockerNetwork network) [Fact] public void GetNameThrowsInvalidOperationException() { - _ = Assert.Throws(() => new TestcontainersNetworkBuilder() + _ = Assert.Throws(() => new NetworkBuilder() .WithName(NetworkName) .Build() .Name); @@ -74,9 +74,9 @@ public async Task CreateNetworkAssignsLabels() } [UsedImplicitly] - public sealed class DockerNetwork : IDockerNetwork, IAsyncLifetime + public sealed class DockerNetwork : INetwork, IAsyncLifetime { - private readonly IDockerNetwork network = new TestcontainersNetworkBuilder() + private readonly INetwork network = new NetworkBuilder() .WithName(NetworkName) .WithOption(Option.Key, Option.Value) .WithLabel(Label.Key, Label.Value)