-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from cake-contrib/feature/0.14.0
Feature/0.14.0
- Loading branch information
Showing
23 changed files
with
908 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using Cake.Npm.Set; | ||
|
||
namespace Cake.Npm.Tests.Set | ||
{ | ||
internal sealed class NpmSetToolFixture : NpmFixture<NpmSetSettings> | ||
{ | ||
public NpmSetToolFixture() | ||
{ | ||
} | ||
|
||
protected override void RunTool() | ||
{ | ||
var tool = new NpmSetTool(FileSystem, Environment, ProcessRunner, Tools, Log); | ||
tool.Set(Settings); | ||
} | ||
} | ||
} |
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,73 @@ | ||
using Cake.Npm.Set; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Cake.Npm.Tests.Set | ||
{ | ||
public class NpmSetToolTests | ||
{ | ||
public sealed class TheSetMethod | ||
{ | ||
[Fact] | ||
public void Should_Redirect_Standard_Error() | ||
{ | ||
var fixture = new NpmSetToolFixture(); | ||
fixture.Settings.RedirectStandardError = true; | ||
fixture.Settings.Key = "progress"; | ||
fixture.Settings.Value = "false"; | ||
var result = fixture.Run(); | ||
|
||
Assert.True(result.Process.RedirectStandardError); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
var fixture = new NpmSetToolFixture(); | ||
fixture.Settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Mandatory_Arguments() | ||
{ | ||
// Given | ||
var fixture = new NpmSetToolFixture(); | ||
fixture.Settings.Key = "progress"; | ||
fixture.Settings.Value = "false"; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
result.Args.ShouldStartWith("set"); | ||
} | ||
|
||
[Theory] | ||
[InlineData("progress", "false", false, "\"progress\"=\"false\"")] | ||
[InlineData("progress", "false", true, "\"progress\"=\"false\" -g")] | ||
[InlineData("progress state", "hello world", true, "\"progress state\"=\"hello world\" -g")] | ||
public void Should_Create_Set_Command_Arguments(string key, string value, bool global, string expected) | ||
{ | ||
// Given | ||
var fixture = new NpmSetToolFixture(); | ||
fixture.Settings.Key = key; | ||
fixture.Settings.Value = value; | ||
fixture.Settings.Global = global; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
result.Args.ShouldEndWith(expected); | ||
} | ||
|
||
} | ||
} | ||
} |
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,17 @@ | ||
using Cake.Npm.Update; | ||
|
||
namespace Cake.Npm.Tests.Update | ||
{ | ||
internal sealed class NpmUpdateToolFixture : NpmFixture<NpmUpdateSettings> | ||
{ | ||
public NpmUpdateToolFixture() | ||
{ | ||
} | ||
|
||
protected override void RunTool() | ||
{ | ||
var tool = new NpmUpdateTool(FileSystem, Environment, ProcessRunner, Tools, Log); | ||
tool.Update(Settings); | ||
} | ||
} | ||
} |
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,64 @@ | ||
using Cake.Npm.Update; | ||
using Xunit; | ||
|
||
namespace Cake.Npm.Tests.Update | ||
{ | ||
public class NpmUpdateToolTests | ||
{ | ||
public sealed class TheUpdateMethod | ||
{ | ||
[Fact] | ||
public void Should_Redirect_Standard_Error() | ||
{ | ||
var fixture = new NpmUpdateToolFixture(); | ||
fixture.Settings.RedirectStandardError = true; | ||
|
||
var result = fixture.Run(); | ||
|
||
Assert.True(result.Process.RedirectStandardError); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
var fixture = new NpmUpdateToolFixture(); | ||
fixture.Settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Mandatory_Arguments() | ||
{ | ||
// Given | ||
var fixture = new NpmUpdateToolFixture(); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("update", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Include_Global_Flag() | ||
{ | ||
// Given | ||
var fixture = new NpmUpdateToolFixture(); | ||
fixture.Settings.UpdateGlobalPackages(); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("update -g", result.Args); | ||
} | ||
|
||
} | ||
} | ||
} |
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,20 @@ | ||
using System.Text; | ||
using Cake.Npm.Version; | ||
|
||
namespace Cake.Npm.Tests.Version | ||
{ | ||
internal sealed class NpmVersionToolFixture : NpmFixture<NpmVersionSettings> | ||
{ | ||
public NpmVersionToolFixture() | ||
{ | ||
} | ||
|
||
protected override void RunTool() | ||
{ | ||
var tool = new NpmVersionTool(FileSystem, Environment, ProcessRunner, Tools, Log); | ||
Version = tool.Version(Settings); | ||
} | ||
|
||
public string Version { get; private set; } | ||
} | ||
} |
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,102 @@ | ||
using Cake.Core; | ||
using Shouldly; | ||
using Xunit; | ||
|
||
namespace Cake.Npm.Tests.Version | ||
{ | ||
public class NpmVersionToolTests | ||
{ | ||
public sealed class TheVersionMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
var fixture = new NpmVersionToolFixture(); | ||
fixture.Settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => fixture.Run()); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Add_Mandatory_Arguments() | ||
{ | ||
// Given | ||
var fixture = new NpmVersionToolFixture(); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("version", result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Determine_Version_From_StandardOutput() | ||
{ | ||
string[] versionInfo = new[] | ||
{ | ||
"{", | ||
" npm: '5.8.0',", | ||
" ares: '1.10.1-DEV',", | ||
" cldr: '32.0',", | ||
" http_parser: '2.8.0',", | ||
" icu: '60.1',", | ||
" modules: '57',", | ||
" nghttp2: '1.25.0',", | ||
" node: '8.11.1',", | ||
" openssl: '1.0.2o',", | ||
" tz: '2017c',", | ||
" unicode: '10.0',", | ||
" uv: '1.19.1',", | ||
" v8: '6.2.414.50',", | ||
" zlib: '1.2.11'", | ||
"}", | ||
"", | ||
"", | ||
"╭─────────────────────────────────────╮", | ||
"│ │", | ||
"│ Update available 5.6.0 → 6.1.0 │", | ||
"│ Run npm i -g npm to update │", | ||
"│ │", | ||
"╰─────────────────────────────────────╯" | ||
}; | ||
|
||
// Given | ||
var fixture = new NpmVersionToolFixture(); | ||
fixture.ProcessRunner.Process.SetStandardOutput(versionInfo); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
fixture.Version.ShouldBe("5.8.0"); | ||
} | ||
|
||
[Theory] | ||
[InlineData("{npm: '1.0.0'}", "1.0.0")] | ||
[InlineData("{ npm: '1.0.0',\r\n{stuff: '0.0.1' }", "1.0.0")] | ||
[InlineData("", "")] | ||
[InlineData(null, "")] | ||
[InlineData("not valid", "")] | ||
public void Should_Determine_Version_From_StandardOutput_Scenarios(string standardOutput, string expectedVersion) | ||
{ | ||
string[] output = standardOutput.SplitLines(); | ||
|
||
// Given | ||
var fixture = new NpmVersionToolFixture(); | ||
fixture.ProcessRunner.Process.SetStandardOutput(output); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
fixture.Version.ShouldBe(expectedVersion); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.