-
-
Notifications
You must be signed in to change notification settings - Fork 59
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 #667 from adamralph/fix-nulls-2.5
fix null usage
- Loading branch information
Showing
11 changed files
with
242 additions
and
92 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
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,148 @@ | ||
using System; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using MinVerTests.Infra; | ||
using Xunit; | ||
|
||
namespace MinVerTests.Packages | ||
{ | ||
public static class OptionMasking | ||
{ | ||
[Theory] | ||
[InlineData("patch")] | ||
public static async Task AutoIncrementBackToDefault(string value) | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
FileSystem.EnsureEmptyDirectory(path); | ||
|
||
await Git.Init(path); | ||
await Git.Commit(path); | ||
await Git.Tag(path, "2.3.4"); | ||
await Git.Commit(path); | ||
|
||
var envVars = ("MinVerAutoIncrement".ToAltCase(), "minor"); | ||
var args = $"--auto-increment {value}"; | ||
|
||
var expected = Package.WithVersion(2, 3, 5, new[] { "alpha", "0" }, 1); | ||
|
||
// act | ||
var cli = await MinVerCli.ReadAsync(path, args: args, envVars: envVars); | ||
|
||
// assert | ||
Assert.Equal(expected.Version, cli.StandardOutput.Trim()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("\"\"")] | ||
|
||
public static async Task BuildMetadataBackToDefault(string value) | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
FileSystem.EnsureEmptyDirectory(path); | ||
|
||
var envVars = ("MinVerBuildMetadata", "build.123"); | ||
var args = $"--build-metadata {value}"; | ||
|
||
var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" }, 0); | ||
|
||
// act | ||
var cli = await MinVerCli.ReadAsync(path, args: args, envVars: envVars); | ||
|
||
// assert | ||
Assert.Equal(expected.Version, cli.StandardOutput.Trim()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("alpha")] | ||
public static async Task DefaultPreReleasePhaseBackToDefault(string value) | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
FileSystem.EnsureEmptyDirectory(path); | ||
|
||
await Git.Init(path); | ||
await Git.Commit(path); | ||
await Git.Tag(path, "2.3.4"); | ||
await Git.Commit(path); | ||
|
||
var envVars = ("MinVerDefaultPreReleasePhase".ToAltCase(), "preview"); | ||
var args = $"--default-pre-release-phase {value}"; | ||
|
||
var expected = Package.WithVersion(2, 3, 5, new[] { "alpha", "0" }, 1); | ||
|
||
// act | ||
var cli = await MinVerCli.ReadAsync(path, args: args, envVars: envVars); | ||
|
||
// assert | ||
Assert.Equal(expected.Version, cli.StandardOutput.Trim()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("0.0")] | ||
public static async Task MinimumMajorMinorBackToDefault(string value) | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
FileSystem.EnsureEmptyDirectory(path); | ||
|
||
await Git.Init(path); | ||
await Git.Commit(path); | ||
await Git.Tag(path, "2.3.4"); | ||
|
||
var envVars = ("MinVerMinimumMajorMinor".ToAltCase(), "3.0"); | ||
var args = $"--minimum-major-minor {value}"; | ||
|
||
var expected = Package.WithVersion(2, 3, 4); | ||
|
||
// act | ||
var cli = await MinVerCli.ReadAsync(path, args: args, envVars: envVars); | ||
|
||
// assert | ||
Assert.Equal(expected.Version, cli.StandardOutput.Trim()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("\"\"")] | ||
public static async Task TagPrefixBackToDefault(string value) | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
FileSystem.EnsureEmptyDirectory(path); | ||
|
||
await Git.Init(path); | ||
await Git.Commit(path); | ||
await Git.Tag(path, "2.3.4-alpha.5"); | ||
|
||
var envVars = ("MinVerTagPrefix", "v."); | ||
var args = $"--tag-prefix {value}"; | ||
|
||
var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" }); | ||
|
||
// act | ||
var cli = await MinVerCli.ReadAsync(path, args: args, envVars: envVars); | ||
|
||
// assert | ||
Assert.Equal(expected.Version, cli.StandardOutput.Trim()); | ||
} | ||
|
||
[Theory] | ||
[InlineData("info")] | ||
public static async Task VerbosityBackToDefault(string value) | ||
{ | ||
// arrange | ||
var path = MethodBase.GetCurrentMethod().GetTestDirectory(); | ||
FileSystem.EnsureEmptyDirectory(path); | ||
|
||
var envVars = ("MinVerVerbosity", "error"); | ||
var args = $"--verbosity {value}"; | ||
|
||
// act | ||
var cli = await MinVerCli.ReadAsync(path, args: args, envVars: envVars); | ||
|
||
// assert | ||
Assert.Contains("MinVer:", cli.StandardError, StringComparison.Ordinal); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.