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

Feature DeleteIfExists on ContainerBuilder #206

Merged
merged 6 commits into from
Sep 14, 2021
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
29 changes: 29 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,34 @@
"sudoer",
"typeof",
"wdlp"
],
"yaml.customTags": [
"!And",
"!And sequence",
"!If",
"!If sequence",
"!Not",
"!Not sequence",
"!Equals",
"!Equals sequence",
"!Or",
"!Or sequence",
"!FindInMap",
"!FindInMap sequence",
"!Base64",
"!Join",
"!Join sequence",
"!Cidr",
"!Ref",
"!Sub",
"!Sub sequence",
"!GetAtt",
"!GetAZs",
"!ImportValue",
"!ImportValue sequence",
"!Select",
"!Select sequence",
"!Split",
"!Split sequence"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Documentation: https://github.com/mariotoffia/FluentDocker
</PropertyGroup>

<ItemGroup>
<PackageReference Include="GitVersionTask" Version="5.3.7" PrivateAssets="All" />
<!--<PackageReference Include="GitVersionTask" Version="5.3.7" PrivateAssets="All" />-->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
<PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
Expand Down
8 changes: 7 additions & 1 deletion Ductus.FluentDocker.Tests/Ductus.FluentDocker.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<EmbeddedResource Include="Compose\redis\Dockerfile" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<None Update="Resources\ComposeTests\MongoDbAndNetwork\docker-compose.yml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -60,6 +60,12 @@
<None Update="Resources\Scripts\envtest.sh">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Model\Containers\inspect.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Model\Containers\inspect_no_create.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ public static void Initialize(TestContext ctx)
Utilities.EnsureImage("postgres:9.6-alpine", TimeSpan.FromMinutes(1.0));
}

[TestMethod]
[TestCategory("CI")]
public void VersionInfoShallBePossibleToRetrieve()
{
var v = Fd.Version();
Assert.IsTrue(v != null && v.Length > 0);
}
[TestMethod]
[TestCategory("CI")]
public void BuildContainerRenderServiceInStoppedMode()
Expand Down Expand Up @@ -500,6 +493,31 @@ public void ReuseOfExistingContainerShallWork()
}
}

[TestMethod]
[TestCategory("CI")]
public void DeleteIfExistsWithContainerShallWork()
{
var name = Guid.NewGuid().ToString();

var container = Fd.UseContainer()
.UseImage("postgres:9.6-alpine")
.WithName($"name-{name}")
.Build();

var id = container.Id;

using (var c = Fd
.UseContainer()
.DeleteIfExists()
.UseImage("postgres:9.6-alpine")
.WithName($"name-{name}")
.Build())
{
// Ids should not be equal - since deleted and then created.
AreNotEqual(id, c.Id);
}
}

[TestMethod]
[TestCategory("CI")]
public void PullContainerBeforeRunningShallWork()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,5 +335,23 @@ public void Issue94()
Assert.AreEqual("1", zookeeper.InstanceId);
}
}

[TestMethod]
public void Issue190()
{
var file = Path.Combine(Directory.GetCurrentDirectory(),
(TemplateString)"Resources/hellotest/docker-compose.yml");

using (var svc = Fd.UseContainer()
.FromComposeFile(file)
.RemoveNonTaggedImages()
.ForceBuild()
.Build()
.Start())
{
}

// Now the custom build image should be removed!
}
}
}
22 changes: 22 additions & 0 deletions Ductus.FluentDocker.Tests/Model/Containers/ContainerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Ductus.FluentDocker.Model.Common;
using Ductus.FluentDocker.Extensions;
using Ductus.FluentDocker.Model.Containers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

namespace Ductus.FluentDocker.Tests.Model.Containers
{
[TestClass]
public class ContainerTests
{
[TestMethod]
public void TestWithNoCreated()
{
var data = ((TemplateString)"Model/Containers/inspect_no_create.json").FromFile();
var obj = JsonConvert.DeserializeObject<Container>(data);

Assert.AreEqual(obj.Created, default(System.DateTime));
}

}
}
Loading