-
-
Notifications
You must be signed in to change notification settings - Fork 732
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
GH472: Added OctoPack tool #1218
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Cake.Common.Tests/Fixtures/Tools/OctopusDeployPackerFixture.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,25 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Common.Tools.OctopusDeploy; | ||
using Cake.Testing.Fixtures; | ||
|
||
namespace Cake.Common.Tests.Fixtures.Tools | ||
{ | ||
internal sealed class OctopusDeployPackerFixture : ToolFixture<OctopusPackSettings> | ||
{ | ||
public string Id { get; set; } | ||
|
||
public OctopusDeployPackerFixture() | ||
: base("octo.exe") | ||
{ | ||
} | ||
|
||
protected override void RunTool() | ||
{ | ||
var tool = new OctopusDeployPacker(FileSystem, Environment, ProcessRunner, Tools); | ||
tool.Pack(Id, Settings); | ||
} | ||
} | ||
} |
196 changes: 196 additions & 0 deletions
196
src/Cake.Common.Tests/Unit/Tools/OctopusDeploy/OctoPackTests.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,196 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Cake.Common.Tests.Fixtures.Tools; | ||
using Xunit; | ||
|
||
namespace Cake.Common.Tests.Unit.Tools.OctopusDeploy | ||
{ | ||
public sealed class OctoPackTests | ||
{ | ||
public sealed class ThePackMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Id_Is_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
Assert.IsArgumentNullException(result, "id"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Id_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Version_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.Version = "1.2.3"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --version 1.2.3", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_OutFolder_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.OutFolder = "out"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --outFolder \"/Working/out\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_BasePath_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.BasePath = "base"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --basePath \"/Working/base\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Author_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.Author = "author"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --author \"author\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Title_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.Title = "title"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --title \"title\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Description_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.Description = "description"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --description \"description\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_ReleaseNotes_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.ReleaseNotes = "releasenotes"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --releaseNotes \"releasenotes\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_ReleaseNotesFile_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.ReleaseNotesFile = "releasenotes.md"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --releaseNotesFile \"/Working/releasenotes.md\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Include_To_Arguments_If_Not_Null() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.Include = new[] | ||
{ | ||
"bin/*.dll", | ||
"bin/*.pdb" | ||
}; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --include \"bin/*.dll\" --include \"bin/*.pdb\"", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Overwrite_To_Arguments_If_True() | ||
{ | ||
// Given | ||
var fixture = new OctopusDeployPackerFixture(); | ||
fixture.Id = "MyPackage"; | ||
fixture.Settings.Overwrite = true; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("pack --id MyPackage --overwrite", result.Args); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We normally divides the Arrange,Act,Assert in
Given
/When
/Then
comments.Would this be possible to change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I prefer to skip the comments and just be strict in dividing the test using linebreaks :) But I'll change it so it matches the rest of the test suite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect :)