Skip to content

Commit

Permalink
Adds ncrunch settings, template for docker-compose unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaMarkic committed Jul 25, 2018
1 parent 9c231ec commit 8ff3d86
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/Cake.Docker.Tests/Build/DockerBuildFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class DockerBuildFixture : ToolFixture<DockerImageBuildSettings>, ICakeCo

public IRegistry Registry => Registry;

public ICakeDataResolver Data => throw new NotImplementedException();

public DockerBuildFixture(): base("docker")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
Expand Down
13 changes: 7 additions & 6 deletions src/Cake.Docker.Tests/Cake.Docker.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake" Version="0.26.0" />
<PackageReference Include="Cake.Testing" Version="0.26.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="Cake" Version="0.28.0" />
<PackageReference Include="Cake.Testing" Version="0.28.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="NSubstitute" Version="3.1.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
38 changes: 38 additions & 0 deletions src/Cake.Docker.Tests/Compose/Exec/DockerComposeExecFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Cake.Core;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Testing.Fixtures;
using System;

namespace Cake.Docker.Tests.Compose.Exec
{
public class DockerComposeExecFixture : ToolFixture<DockerComposeExecSettings>, ICakeContext
{
public string Service { get; set; }
public string Command { get; set; }
public string[] Args { get; set; } = new string[0];

IFileSystem ICakeContext.FileSystem => FileSystem;

ICakeEnvironment ICakeContext.Environment => Environment;

public ICakeLog Log => Log;

ICakeArguments ICakeContext.Arguments => throw new NotImplementedException();

IProcessRunner ICakeContext.ProcessRunner => ProcessRunner;

public IRegistry Registry => Registry;

public ICakeDataResolver Data => Data;

public DockerComposeExecFixture() : base("DockerCompose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
}
protected override void RunTool()
{
this.DockerComposeExec(Settings, Service, Command, Args);
}
}
}
24 changes: 24 additions & 0 deletions src/Cake.Docker.Tests/Compose/Exec/DockerComposeExecTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using NUnit.Framework;

namespace Cake.Docker.Tests.Compose.Exec
{
[TestFixture]
public class DockerComposeExecTest
{
// TODO fixture can't find docker-compose for some reason
//[Test]
//public void WhenDisablePseudoTtyIsSet_AddsItsArgument()
//{
// var fixture = new DockerComposeExecFixture
// {
// Settings = new DockerComposeExecSettings(),
// Service = "service",
// Command = "command"
// };

// var actual = fixture.Run();

// Assert.That(actual.Args, Is.EqualTo("docker-compose service command"));
//}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class DockerRegistryLoginFixture : ToolFixture<DockerRegistryLoginSetting

public IRegistry Registry => Registry;

public ICakeDataResolver Data => throw new NotImplementedException();

public DockerRegistryLoginFixture(): base("docker")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Docker.v3.ncrunchsolution
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<SolutionConfiguration>
<Settings>
<AllowParallelTestExecution>True</AllowParallelTestExecution>
<SolutionConfigured>True</SolutionConfigured>
</Settings>
</SolutionConfiguration>

0 comments on commit 8ff3d86

Please sign in to comment.