-
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.
- Loading branch information
1 parent
332429b
commit 1e2d419
Showing
3 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
src/Cake.Npm.Tests/DistTag/NpmCiSettingsExtensionsTests.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,83 @@ | ||
namespace Cake.Npm.Tests.Ci | ||
{ | ||
using Cake.Npm.Ci; | ||
using Shouldly; | ||
using System; | ||
using Xunit; | ||
|
||
public sealed class NpmUpdateSettingsExtensionsTests | ||
{ | ||
public sealed class TheForProductionMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
NpmCiSettings settings = null; | ||
|
||
// When | ||
var result = Record.Exception(() => settings.ForProduction()); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
[Fact] | ||
public void Should_Set_Production() | ||
{ | ||
// Given | ||
var settings = new NpmCiSettings(); | ||
|
||
// When | ||
settings.ForProduction(); | ||
|
||
// Then | ||
settings.Production.ShouldBe(true); | ||
} | ||
} | ||
|
||
public sealed class TheFromRegistryMethod | ||
{ | ||
[Fact] | ||
public void Should_Throw_If_Settings_Are_Null() | ||
{ | ||
// Given | ||
NpmCiSettings settings = null; | ||
var registry = new Uri("https://myregistry.com"); | ||
|
||
// When | ||
var result = Record.Exception(() => settings.FromRegistry(registry)); | ||
|
||
// Then | ||
result.IsArgumentNullException("settings"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Throw_If_Registry_Is_Null() | ||
{ | ||
// Given | ||
var settings = new NpmCiSettings(); | ||
Uri registry = null; | ||
|
||
// When | ||
var result = Record.Exception(() => settings.FromRegistry(registry)); | ||
|
||
// Then | ||
result.IsArgumentNullException("registry"); | ||
} | ||
|
||
[Fact] | ||
public void Should_Set_Registry() | ||
{ | ||
// Given | ||
var settings = new NpmCiSettings(); | ||
var registry = new Uri("https://myregistry.com"); | ||
|
||
// When | ||
var result = settings.FromRegistry(registry); | ||
|
||
// Then | ||
result.Registry.ShouldBe(registry); | ||
} | ||
} | ||
} | ||
} |
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.DistTag; | ||
|
||
namespace Cake.Npm.Tests.DistTag | ||
{ | ||
internal sealed class NpmDistTagAddToolFixture : NpmFixture<NpmDistTagAddSettings> | ||
{ | ||
public NpmDistTagAddToolFixture() | ||
{ | ||
} | ||
|
||
protected override void RunTool() | ||
{ | ||
var tool = new NpmDistTagTool(FileSystem, Environment, ProcessRunner, Tools, Log); | ||
tool.RunDistTag(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,125 @@ | ||
using System; | ||
using Cake.Core.Diagnostics; | ||
using Cake.Npm.DistTag; | ||
using Xunit; | ||
|
||
namespace Cake.Npm.Tests.DistTag | ||
{ | ||
public class NpmDistTagToolTests | ||
{ | ||
public sealed class TheRunDistTagMethod | ||
{ | ||
[Fact] | ||
public void Should_Redirect_Standard_Error() | ||
{ | ||
var fixture = new NpmDistTagToolFixture(); | ||
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 NpmCiToolFixture(); | ||
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 NpmCiToolFixture(); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("ci", result.Args); | ||
} | ||
|
||
[Theory] | ||
[InlineData(NpmLogLevel.Default, "ci")] | ||
[InlineData(NpmLogLevel.Info, "ci --loglevel info")] | ||
[InlineData(NpmLogLevel.Silent, "ci --silent")] | ||
[InlineData(NpmLogLevel.Silly, "ci --loglevel silly")] | ||
[InlineData(NpmLogLevel.Verbose, "ci --loglevel verbose")] | ||
[InlineData(NpmLogLevel.Warn, "ci --warn")] | ||
[InlineData(NpmLogLevel.Error, "ci --loglevel error")] | ||
[InlineData(NpmLogLevel.Http, "ci --loglevel http")] | ||
public void Should_Add_LogLevel_To_Arguments_If_Not_Null( | ||
NpmLogLevel logLevel, | ||
string expected) | ||
{ | ||
// Given | ||
var fixture = new NpmCiToolFixture(); | ||
fixture.Settings.LogLevel = logLevel; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal(expected, result.Args); | ||
} | ||
|
||
[Theory] | ||
[InlineData(Verbosity.Diagnostic, "ci --loglevel verbose")] | ||
[InlineData(Verbosity.Minimal, "ci --warn")] | ||
[InlineData(Verbosity.Normal, "ci")] | ||
[InlineData(Verbosity.Quiet, "ci --silent")] | ||
[InlineData(Verbosity.Verbose, "ci --loglevel info")] | ||
public void Should_Use_Cake_LogLevel_If_LogLevel_Is_Set_To_Default( | ||
Verbosity verbosity, | ||
string expected) | ||
{ | ||
// Given | ||
var fixture = new NpmCiToolFixture(); | ||
fixture.Settings.CakeVerbosityLevel = verbosity; | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal(expected, result.Args); | ||
} | ||
|
||
[Fact] | ||
public void Should_Include_Production_Flag() | ||
{ | ||
// Given | ||
var fixture = new NpmCiToolFixture(); | ||
fixture.Settings.ForProduction(); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("ci --production", result.Args); | ||
} | ||
|
||
|
||
[Fact] | ||
public void Should_Include_Registry_Args_If_Set() | ||
{ | ||
// Given | ||
var fixture = new NpmCiToolFixture(); | ||
fixture.Settings.FromRegistry(new Uri("https://myregistry/")); | ||
|
||
// When | ||
var result = fixture.Run(); | ||
|
||
// Then | ||
Assert.Equal("ci --registry https://myregistry/", result.Args); | ||
} | ||
} | ||
} | ||
} |