Skip to content

Commit 1e2d419

Browse files
committed
temp
1 parent 332429b commit 1e2d419

File tree

3 files changed

+225
-0
lines changed

3 files changed

+225
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
namespace Cake.Npm.Tests.Ci
2+
{
3+
using Cake.Npm.Ci;
4+
using Shouldly;
5+
using System;
6+
using Xunit;
7+
8+
public sealed class NpmUpdateSettingsExtensionsTests
9+
{
10+
public sealed class TheForProductionMethod
11+
{
12+
[Fact]
13+
public void Should_Throw_If_Settings_Are_Null()
14+
{
15+
// Given
16+
NpmCiSettings settings = null;
17+
18+
// When
19+
var result = Record.Exception(() => settings.ForProduction());
20+
21+
// Then
22+
result.IsArgumentNullException("settings");
23+
}
24+
[Fact]
25+
public void Should_Set_Production()
26+
{
27+
// Given
28+
var settings = new NpmCiSettings();
29+
30+
// When
31+
settings.ForProduction();
32+
33+
// Then
34+
settings.Production.ShouldBe(true);
35+
}
36+
}
37+
38+
public sealed class TheFromRegistryMethod
39+
{
40+
[Fact]
41+
public void Should_Throw_If_Settings_Are_Null()
42+
{
43+
// Given
44+
NpmCiSettings settings = null;
45+
var registry = new Uri("https://myregistry.com");
46+
47+
// When
48+
var result = Record.Exception(() => settings.FromRegistry(registry));
49+
50+
// Then
51+
result.IsArgumentNullException("settings");
52+
}
53+
54+
[Fact]
55+
public void Should_Throw_If_Registry_Is_Null()
56+
{
57+
// Given
58+
var settings = new NpmCiSettings();
59+
Uri registry = null;
60+
61+
// When
62+
var result = Record.Exception(() => settings.FromRegistry(registry));
63+
64+
// Then
65+
result.IsArgumentNullException("registry");
66+
}
67+
68+
[Fact]
69+
public void Should_Set_Registry()
70+
{
71+
// Given
72+
var settings = new NpmCiSettings();
73+
var registry = new Uri("https://myregistry.com");
74+
75+
// When
76+
var result = settings.FromRegistry(registry);
77+
78+
// Then
79+
result.Registry.ShouldBe(registry);
80+
}
81+
}
82+
}
83+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Cake.Npm.DistTag;
2+
3+
namespace Cake.Npm.Tests.DistTag
4+
{
5+
internal sealed class NpmDistTagAddToolFixture : NpmFixture<NpmDistTagAddSettings>
6+
{
7+
public NpmDistTagAddToolFixture()
8+
{
9+
}
10+
11+
protected override void RunTool()
12+
{
13+
var tool = new NpmDistTagTool(FileSystem, Environment, ProcessRunner, Tools, Log);
14+
tool.RunDistTag(Settings);
15+
}
16+
}
17+
}
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
using System;
2+
using Cake.Core.Diagnostics;
3+
using Cake.Npm.DistTag;
4+
using Xunit;
5+
6+
namespace Cake.Npm.Tests.DistTag
7+
{
8+
public class NpmDistTagToolTests
9+
{
10+
public sealed class TheRunDistTagMethod
11+
{
12+
[Fact]
13+
public void Should_Redirect_Standard_Error()
14+
{
15+
var fixture = new NpmDistTagToolFixture();
16+
fixture.Settings.RedirectStandardError = true;
17+
18+
var result = fixture.Run();
19+
20+
Assert.True(result.Process.RedirectStandardError);
21+
}
22+
23+
[Fact]
24+
public void Should_Throw_If_Settings_Are_Null()
25+
{
26+
// Given
27+
var fixture = new NpmCiToolFixture();
28+
fixture.Settings = null;
29+
30+
// When
31+
var result = Record.Exception(() => fixture.Run());
32+
33+
// Then
34+
result.IsArgumentNullException("settings");
35+
}
36+
37+
[Fact]
38+
public void Should_Add_Mandatory_Arguments()
39+
{
40+
// Given
41+
var fixture = new NpmCiToolFixture();
42+
43+
// When
44+
var result = fixture.Run();
45+
46+
// Then
47+
Assert.Equal("ci", result.Args);
48+
}
49+
50+
[Theory]
51+
[InlineData(NpmLogLevel.Default, "ci")]
52+
[InlineData(NpmLogLevel.Info, "ci --loglevel info")]
53+
[InlineData(NpmLogLevel.Silent, "ci --silent")]
54+
[InlineData(NpmLogLevel.Silly, "ci --loglevel silly")]
55+
[InlineData(NpmLogLevel.Verbose, "ci --loglevel verbose")]
56+
[InlineData(NpmLogLevel.Warn, "ci --warn")]
57+
[InlineData(NpmLogLevel.Error, "ci --loglevel error")]
58+
[InlineData(NpmLogLevel.Http, "ci --loglevel http")]
59+
public void Should_Add_LogLevel_To_Arguments_If_Not_Null(
60+
NpmLogLevel logLevel,
61+
string expected)
62+
{
63+
// Given
64+
var fixture = new NpmCiToolFixture();
65+
fixture.Settings.LogLevel = logLevel;
66+
67+
// When
68+
var result = fixture.Run();
69+
70+
// Then
71+
Assert.Equal(expected, result.Args);
72+
}
73+
74+
[Theory]
75+
[InlineData(Verbosity.Diagnostic, "ci --loglevel verbose")]
76+
[InlineData(Verbosity.Minimal, "ci --warn")]
77+
[InlineData(Verbosity.Normal, "ci")]
78+
[InlineData(Verbosity.Quiet, "ci --silent")]
79+
[InlineData(Verbosity.Verbose, "ci --loglevel info")]
80+
public void Should_Use_Cake_LogLevel_If_LogLevel_Is_Set_To_Default(
81+
Verbosity verbosity,
82+
string expected)
83+
{
84+
// Given
85+
var fixture = new NpmCiToolFixture();
86+
fixture.Settings.CakeVerbosityLevel = verbosity;
87+
88+
// When
89+
var result = fixture.Run();
90+
91+
// Then
92+
Assert.Equal(expected, result.Args);
93+
}
94+
95+
[Fact]
96+
public void Should_Include_Production_Flag()
97+
{
98+
// Given
99+
var fixture = new NpmCiToolFixture();
100+
fixture.Settings.ForProduction();
101+
102+
// When
103+
var result = fixture.Run();
104+
105+
// Then
106+
Assert.Equal("ci --production", result.Args);
107+
}
108+
109+
110+
[Fact]
111+
public void Should_Include_Registry_Args_If_Set()
112+
{
113+
// Given
114+
var fixture = new NpmCiToolFixture();
115+
fixture.Settings.FromRegistry(new Uri("https://myregistry/"));
116+
117+
// When
118+
var result = fixture.Run();
119+
120+
// Then
121+
Assert.Equal("ci --registry https://myregistry/", result.Args);
122+
}
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)