-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
NF.Tool.ReleaseNoteMaker/NF.Tool.ReleaseNoteMaker.Tests/TestCheck.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,52 @@ | ||
using NF.Tool.ReleaseNoteMaker.CLI; | ||
using NF.Tool.ReleaseNoteMaker.CLI.Impl; | ||
using Spectre.Console; | ||
using Spectre.Console.Testing; | ||
|
||
namespace NF.Tool.ReleaseNoteMaker.Tests | ||
{ | ||
[TestClass] | ||
[DoNotParallelize] | ||
public sealed class TestCheck | ||
{ | ||
public required TestContext TestContext { get; set; } | ||
|
||
[TestInitialize] | ||
public void TestInitialize() | ||
{ | ||
string testName = TestContext.TestName!; | ||
string testDirectory = Path.Combine(TestContext.DeploymentDirectory!, testName); | ||
Directory.CreateDirectory(testDirectory); | ||
File.Copy("Template.tt", $"{testDirectory}/Template.tt"); | ||
File.Copy("ReleaseNote.config.toml", $"{testDirectory}/ReleaseNote.config.toml"); | ||
Directory.SetCurrentDirectory(testDirectory); | ||
} | ||
|
||
[TestCleanup] | ||
public void TestCleanup() | ||
{ | ||
Directory.SetCurrentDirectory(TestContext.DeploymentDirectory!); | ||
} | ||
|
||
[TestMethod] | ||
public async Task TestGitFails() | ||
{ | ||
string branch = "main"; | ||
Cmd.Call("git", $"init --initial-branch={branch}"); | ||
Cmd.Call("git", "config user.name user"); | ||
Cmd.Call("git", "config user.email [email protected]"); | ||
Cmd.Call("git", "add ."); | ||
string message = "Initial Commit"; | ||
Cmd.Call("git", $"commit -m {message}"); | ||
Cmd.Call("git", "checkout -b otherbranch"); | ||
|
||
TestConsole c = new TestConsole(); | ||
AnsiConsole.Console = c; | ||
string[] args = ["check", "--compare-with", "hblaugh"]; | ||
int result = await Program.Main(args); | ||
Assert.AreEqual(1, result); | ||
Assert.IsTrue(c.Output.Contains("git produced output while failing")); | ||
Assert.IsTrue(c.Output.Contains("hblaugh")); | ||
} | ||
} | ||
} |