Skip to content

Commit

Permalink
Update to support Cake 4.0 (#114)
Browse files Browse the repository at this point in the history
* Updates to support Cake 4.0
* Updates readme
* Fixes throw arguments
  • Loading branch information
twenzel committed Jan 19, 2024
1 parent f9b58f7 commit 06bcb12
Show file tree
Hide file tree
Showing 98 changed files with 478 additions and 698 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -14,6 +14,8 @@ Including addin in cake script is easy.

**Cake references**

* 1.3.0: Cake 4.0.0

* 1.2.0: Cake 3.0.0

* 1.1.0: Cake 2.0.0
Expand Down
2 changes: 1 addition & 1 deletion src/.config/dotnet-tools.json
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"version": "4.0.0",
"commands": [
"dotnet-cake"
]
Expand Down
28 changes: 14 additions & 14 deletions src/Cake.Docker.Tests/ArgumentsBuilderExtensionTest.cs
@@ -1,10 +1,10 @@
using Cake.Core.IO;
using NUnit.Framework;
using System;
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Reflection;
using Cake.Core.IO;
using NUnit.Framework;
using NUnit.Framework.Legacy;

namespace Cake.Docker.Tests
{
Expand Down Expand Up @@ -86,7 +86,7 @@ public class GetArgumentFromStringArrayProperty
[Test]
public void WhenGivenStringArrayProperty_FormatsProperly()
{
var actual = ArgumentsBuilderExtension.GetArgumentFromStringArrayProperty(StringsProperty, new string[] { "tubo1", "tubo2" }, isSecret: false);
var actual = ArgumentsBuilderExtension.GetArgumentFromStringArrayProperty(StringsProperty, ["tubo1", "tubo2"], isSecret: false);

CollectionAssert.AreEqual(actual, new DockerArgument[] {
new DockerArgument("--strings", "tubo1", DockerArgumentQuoting.Quoted),
Expand All @@ -107,7 +107,7 @@ public class GetArgumentFromStringArrayListProperty
public void WhenGivenStringArrayProperty_FormatsProperly()
{
var actual = ArgumentsBuilderExtension.GetArgumentFromStringArrayListProperty(
ListStringsProperty, new string[] { "tubo1", "tubo2" }, isSecret: false).Value;
ListStringsProperty, ["tubo1", "tubo2"], isSecret: false).Value;

Assert.That(actual.Key, Is.EqualTo("--list-strings"));
Assert.That(actual.Value, Is.EqualTo("tubo1,tubo2"));
Expand Down Expand Up @@ -286,7 +286,7 @@ public void WhenStringInput_AddsAsArgument()
TestSettings input = new TestSettings { String = "tubo" };

ProcessArgumentBuilder builder = new ProcessArgumentBuilder();
builder.AppendAll("cmd", input, new string[] { "arg1" });
builder.AppendAll("cmd", input, ["arg1"]);
var actual = builder.Render();

Assert.That(actual, Is.EqualTo("cmd --string \"tubo\" arg1"));
Expand All @@ -307,7 +307,7 @@ public void WhenGivenInput_ConvertsProperly()
}

[TestFixture]
public class GetAutoPropertyAttributeOrNull: ArgumentsBuilderExtensionTest
public class GetAutoPropertyAttributeOrNull : ArgumentsBuilderExtensionTest
{
[Test]
public void WhenDecorated_ReturnsAutoPropertyAttribute()
Expand All @@ -326,7 +326,7 @@ public void WhenNotDecorated_ReturnsNull()
}

[TestFixture]
public class GetArgumentFromAutoProperty: ArgumentsBuilderExtensionTest
public class GetArgumentFromAutoProperty : ArgumentsBuilderExtensionTest
{
[Test]
public void WhenGivenValue_FormatsProperly()
Expand Down Expand Up @@ -356,13 +356,13 @@ public void WhenOnlyWhenTrueValue_AndIsTrue_FormatsProperly()
public void WhenDecoratedStrings_FormatsProperly()
{
var attribute = ArgumentsBuilderExtension.GetAutoPropertyAttributeOrNull(DecoratedStringsProperty);
var actual = ArgumentsBuilderExtension.GetArgumentFromAutoProperty(attribute, DecoratedStringsProperty, new string[] {"One=1", "Two=2" });
var actual = ArgumentsBuilderExtension.GetArgumentFromAutoProperty(attribute, DecoratedStringsProperty, new string[] { "One=1", "Two=2" });

Assert.That(actual, Is.EqualTo("-e One=1 -e Two=2"));
}
}
[TestFixture]
public class GetArgumentFromProperty: ArgumentsBuilderExtensionTest
public class GetArgumentFromProperty : ArgumentsBuilderExtensionTest
{
[Test]
public void WhenPreCommand_DoesNotAppearInNormalCommands()
Expand All @@ -382,7 +382,7 @@ public void WhenPreCommand_ItAppearsInPreCommands()
}
}

public class TestSettings: AutoToolSettings
public class TestSettings : AutoToolSettings
{
public string String { get; set; }
public string[] Strings { get; set; }
Expand All @@ -393,7 +393,7 @@ public class TestSettings: AutoToolSettings
public Int64? NullableInt64 { get; set; }
public UInt64? NullableUInt64 { get; set; }
public UInt16? NullableUInt16 { get; set; }
public bool? NullableBool { get; set; }
public bool? NullableBool { get; set; }
public TimeSpan? NullableTimeSpan { get; set; }
public bool Bool { get; set; }
[AutoProperty(Format = "-s {1}")]
Expand All @@ -406,7 +406,7 @@ public class TestSettings: AutoToolSettings
public string PreCommandValue { get; set; }
protected override string[] CollectSecretProperties()
{
return new[] { nameof(Password) };
return [nameof(Password)];
}
}
}
8 changes: 4 additions & 4 deletions src/Cake.Docker.Tests/Build/DockerBuildFixture.cs
@@ -1,9 +1,9 @@
using Cake.Core;
using System;
using Cake.Core;
using Cake.Core.Configuration;
using Cake.Core.Diagnostics;
using Cake.Core.IO;
using Cake.Testing.Fixtures;
using System;

namespace Cake.Docker.Tests.Build
{
Expand All @@ -27,9 +27,9 @@ public class DockerBuildFixture : ToolFixture<DockerImageBuildSettings>, ICakeCo

ICakeConfiguration ICakeContext.Configuration => throw new NotImplementedException();

public DockerBuildFixture(): base("docker")
public DockerBuildFixture() : base("docker")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Cake.Docker.Tests/Cake.Docker.Tests.csproj
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Testing" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NSubstitute" Version="4.4.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
<PackageReference Include="Cake.Testing" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Expand Up @@ -9,7 +9,7 @@ namespace Cake.Docker.Tests.Build
{
public class DockerComposeBuildFixture : ToolFixture<DockerComposeBuildSettings>, ICakeContext
{
public string[] Services { get; set; } = new string[0];
public string[] Services { get; set; } = [];

IFileSystem ICakeContext.FileSystem => FileSystem;

Expand All @@ -29,7 +29,7 @@ public class DockerComposeBuildFixture : ToolFixture<DockerComposeBuildSettings>

public DockerComposeBuildFixture(): base("docker-compose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
Expand Up @@ -11,7 +11,7 @@ public class DockerComposeExecFixture : ToolFixture<DockerComposeExecSettings>,
{
public string Service { get; set; }
public string Command { get; set; }
public string[] Args { get; set; } = new string[0];
public string[] Args { get; set; } = [];

IFileSystem ICakeContext.FileSystem => FileSystem;

Expand All @@ -31,7 +31,7 @@ public class DockerComposeExecFixture : ToolFixture<DockerComposeExecSettings>,

public DockerComposeExecFixture() : base("docker-compose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
Expand Up @@ -31,7 +31,7 @@ public class DockerComposePortFixture : ToolFixture<DockerComposePortSettings>,

public DockerComposePortFixture(): base("docker-compose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Docker.Tests/Compose/Ps/DockerComposePsFixture.cs
Expand Up @@ -9,7 +9,7 @@ namespace Cake.Docker.Tests.Compose.Ps
{
public class DockerComposePsFixture : ToolFixture<DockerComposePsSettings>, ICakeContext
{
public string[] Services { get; set; } = new string[0];
public string[] Services { get; set; } = [];

IFileSystem ICakeContext.FileSystem => FileSystem;

Expand All @@ -29,7 +29,7 @@ public class DockerComposePsFixture : ToolFixture<DockerComposePsSettings>, ICak

public DockerComposePsFixture(): base("docker-compose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
12 changes: 6 additions & 6 deletions src/Cake.Docker.Tests/Compose/Ps/DockerComposePsTest.cs
Expand Up @@ -10,7 +10,7 @@ public void WhenNoServiceAreSet_CommandLineIsCorrect()
{
var fixture = new DockerComposePsFixture
{
Settings = new DockerComposePsSettings { Filters = new[] { "filter" } },
Settings = new DockerComposePsSettings { Filters = ["filter"] },
};

var actual = fixture.Run();
Expand All @@ -23,8 +23,8 @@ public void WhenSingleFilterIsSet_CommandLineIsCorrect()
{
var fixture = new DockerComposePsFixture
{
Settings = new DockerComposePsSettings { Filters = new[] { "filter" } },
Services = new string[] { "serviceA", "serviceB" },
Settings = new DockerComposePsSettings { Filters = ["filter"] },
Services = ["serviceA", "serviceB"],
};

var actual = fixture.Run();
Expand All @@ -37,8 +37,8 @@ public void WhenMultipleFilterIsSet_CommandLineIsCorrect()
{
var fixture = new DockerComposePsFixture
{
Settings = new DockerComposePsSettings { Filters = new[] { "filter1", "filter2" } },
Services = new string[] { "serviceA", "serviceB" },
Settings = new DockerComposePsSettings { Filters = ["filter1", "filter2"] },
Services = ["serviceA", "serviceB"],
};

var actual = fixture.Run();
Expand All @@ -52,7 +52,7 @@ public void WhenQuietIsSet_CommandLineIsCorrect()
var fixture = new DockerComposePsFixture
{
Settings = new DockerComposePsSettings { Quiet = true },
Services = new string[] { "serviceA", "serviceB", "serviceC" },
Services = ["serviceA", "serviceB", "serviceC"],
};

var actual = fixture.Run();
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class DockerComposeRunFixture : ToolFixture<DockerComposeRunSettings>, IC

public DockerComposeRunFixture(): base("docker-compose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Cake.Docker.Tests/Compose/Run/DockerComposeRunTest.cs
Expand Up @@ -25,7 +25,7 @@ public void WhenVolumeIsSet_CommandLineIsCorrect()
var fixture = new DockerComposeRunFixture
{
Command = "cmd",
Settings = new DockerComposeRunSettings { Volume = new[] { "host:guest" } },
Settings = new DockerComposeRunSettings { Volume = ["host:guest"] },
};

var actual = fixture.Run();
Expand All @@ -38,7 +38,7 @@ public void WhenTwoVolumesAreSet_CommandLineIsCorrect()
var fixture = new DockerComposeRunFixture
{
Command = "cmd",
Settings = new DockerComposeRunSettings { Volume = new[] { "host:guest", "host2:guest2" } },
Settings = new DockerComposeRunSettings { Volume = ["host:guest", "host2:guest2"] },
};

var actual = fixture.Run();
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Docker.Tests/Compose/Up/DockerComposeUpFixture.cs
Expand Up @@ -29,7 +29,7 @@ public class DockerComposeUpFixture : ToolFixture<DockerComposeUpSettings>, ICak

public DockerComposeUpFixture(): base("docker-compose")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
Expand Up @@ -30,7 +30,7 @@ public class DockerManifestInspectFixture : ToolFixture<DockerManifestInspectSet

public DockerManifestInspectFixture(): base("docker")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Docker.Tests/Ps/DockerPsFixture.cs
Expand Up @@ -27,7 +27,7 @@ public class DockerPsFixture : ToolFixture<DockerContainerPsSettings>, ICakeCont

public DockerPsFixture(): base("docker")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cake.Docker.Tests/Registry/Login/DockerLoginTest.cs
Expand Up @@ -37,7 +37,7 @@ public void WhenOnlyUsernameIsSet_CommandLineIsCorrect()
public void WhenOnlyPasswordIsSet_ArgumentIsRedacted()
{
var builder = new ProcessArgumentBuilder();
builder.AppendAll("login", new DockerRegistryLoginSettings { Password = "Tubo" }, new string[0]);
builder.AppendAll("login", new DockerRegistryLoginSettings { Password = "Tubo" }, []);

var actual = builder.RenderSafe();

Expand Down
Expand Up @@ -29,7 +29,7 @@ public class DockerRegistryLoginFixture : ToolFixture<DockerRegistryLoginSetting

public DockerRegistryLoginFixture(): base("docker")
{
ProcessRunner.Process.SetStandardOutput(new string[] { });
ProcessRunner.Process.SetStandardOutput(Array.Empty<string>());
}
protected override void RunTool()
{
Expand Down

0 comments on commit 06bcb12

Please sign in to comment.