forked from testcontainers/testcontainers-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[testcontainers#466] #IMPLEMENT 'assemblyName: DotNet.Testcontainers;…
… function: Image Name Substitution'
- Loading branch information
Showing
7 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
tests/DotNet.Testcontainers.Tests/Unit/Builders/TestcontainerBuilderTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
namespace DotNet.Testcontainers.Tests.Unit.Builders; | ||
|
||
using DotNet.Testcontainers.Builders; | ||
using DotNet.Testcontainers.Configurations; | ||
using DotNet.Testcontainers.Containers; | ||
using Images; | ||
using Xunit; | ||
|
||
public class TestcontainerBuilderTest | ||
{ | ||
[Theory] | ||
[InlineData("my.proxy.com", "bar", "my.proxy.com/bar:latest")] | ||
[InlineData("my.proxy.com", "bar:latest", "my.proxy.com/bar:latest")] | ||
[InlineData("my.proxy.com", "bar:1.0.0", "my.proxy.com/bar:1.0.0")] | ||
[InlineData("my.proxy.com/my-path", "bar:1.0.0", "my.proxy.com/my-path/bar:1.0.0")] | ||
[InlineData("my.proxy.com:443", "bar:1.0.0", "my.proxy.com:443/bar:1.0.0")] | ||
[InlineData("my.proxy.com", "foo/bar:1.0.0", "my.proxy.com/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com/my-path", "foo/bar:1.0.0", "my.proxy.com/my-path/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com:443", "foo/bar:1.0.0", "my.proxy.com:443/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com:443/my-path", "foo/bar:1.0.0", "my.proxy.com:443/my-path/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com", "myregistry.azurecr.io/foo/bar:1.0.0", "myregistry.azurecr.io/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com", "myregistry.azurecr.io:443/foo/bar:1.0.0", "myregistry.azurecr.io:443/foo/bar:1.0.0")] | ||
public void ImageNameFromStringIsPrefixedWhenPrefixIsSet(string prefix, string originalImageName, string expectedName) | ||
{ | ||
TestcontainersSettings.DockerHubImagePrefix = prefix; | ||
|
||
var container = new TestcontainersBuilder<TestcontainersContainer>() | ||
.WithImage(originalImageName) | ||
.Build(); | ||
|
||
Assert.Equal(expectedName, container.ImageName); | ||
} | ||
|
||
[Theory] | ||
[InlineData("my.proxy.com", "bar", "my.proxy.com/bar:latest")] | ||
[InlineData("my.proxy.com", "bar:latest", "my.proxy.com/bar:latest")] | ||
[InlineData("my.proxy.com", "bar:1.0.0", "my.proxy.com/bar:1.0.0")] | ||
[InlineData("my.proxy.com/my-path", "bar:1.0.0", "my.proxy.com/my-path/bar:1.0.0")] | ||
[InlineData("my.proxy.com:443", "bar:1.0.0", "my.proxy.com:443/bar:1.0.0")] | ||
[InlineData("my.proxy.com", "foo/bar:1.0.0", "my.proxy.com/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com/my-path", "foo/bar:1.0.0", "my.proxy.com/my-path/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com:443", "foo/bar:1.0.0", "my.proxy.com:443/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com:443/my-path", "foo/bar:1.0.0", "my.proxy.com:443/my-path/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com", "myregistry.azurecr.io/foo/bar:1.0.0", "myregistry.azurecr.io/foo/bar:1.0.0")] | ||
[InlineData("my.proxy.com", "myregistry.azurecr.io:443/foo/bar:1.0.0", "myregistry.azurecr.io:443/foo/bar:1.0.0")] | ||
public void ImageNameFromClassIsPrefixedWhenPrefixIsSet(string prefix, string originalImageName, string expectedName) | ||
{ | ||
TestcontainersSettings.DockerHubImagePrefix = prefix; | ||
|
||
var container = new TestcontainersBuilder<TestcontainersContainer>() | ||
.WithImage(new DockerImage(originalImageName)) | ||
.Build(); | ||
|
||
Assert.Equal(expectedName, container.ImageName); | ||
} | ||
|
||
[Fact] | ||
public void ImageNameIsNotPrefixedWhenPrefixIsNotSet() | ||
{ | ||
TestcontainersSettings.DockerHubImagePrefix = null; | ||
|
||
var container = new TestcontainersBuilder<TestcontainersContainer>() | ||
.WithImage("foo/bar:1.0.0") | ||
.Build(); | ||
|
||
Assert.Equal("foo/bar:1.0.0", container.ImageName); | ||
} | ||
} |