Skip to content

Commit

Permalink
test: TestWithTitleFormatDuplicateVersionRaise
Browse files Browse the repository at this point in the history
  • Loading branch information
netpyoung committed Dec 1, 2024
1 parent 132fade commit 72c12b6
Showing 1 changed file with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using NF.Tool.ReleaseNoteMaker.CLI.Commands;
using NF.Tool.ReleaseNoteMaker.CLI;
using NF.Tool.ReleaseNoteMaker.CLI.Commands;
using NF.Tool.ReleaseNoteMaker.Common.Config;
using NF.Tool.ReleaseNoteMaker.Common.Fragments;
using NF.Tool.ReleaseNoteMaker.Common.Template;
using Spectre.Console;
using Spectre.Console.Testing;

namespace NF.Tool.ReleaseNoteMaker.Tests
{
Expand Down Expand Up @@ -186,7 +189,7 @@ Old text.
[TestMethod]
[DeploymentItem("Template.tt")]
[DeploymentItem("ReleaseNote.config.toml")]
public async Task TestMultipleFileOoStartString()
public async Task TestMultipleFileNoStartString()
{
List<FragmentContent> fragments = new List<FragmentContent>
{
Expand Down Expand Up @@ -223,5 +226,45 @@ public async Task TestMultipleFileOoStartString()
string actual = await File.ReadAllTextAsync("ChangeLog.md");
Assert.AreEqual(expected, actual);
}

[TestMethod]
[DeploymentItem("Template.tt")]
[DeploymentItem("ReleaseNote.config.toml")]
[DeploymentItem("SampleData/Case001/123.feature", "ChangeLog.d/")]
public async Task TestWithTitleFormatDuplicateVersionRaise()
{
Assert.IsTrue(File.Exists("ChangeLog.d/123.feature"));

File.WriteAllText("ReleaseNote.config.toml", """
[ReleaseNote.Maker]
Directory = "ChangeLog.d"
OutputFileName = "{0}-notes.md"
TemplateFilePath = "Template.tt"
TitleFormat = "{0} {1} ({2})"
""");

string[] args = [
"build",
"--version", "7.8.9",
"--name", "foo",
"--date", "01-01-2001",
"--yes",
];

int result = await Program.Main(args);
Assert.AreEqual(0, result);
Console.Write(File.ReadAllText("{0}-notes.md"));
Assert.IsTrue(File.Exists("ChangeLog.d/123.feature"));



TestConsole c = new TestConsole();
AnsiConsole.Console = c;
result = await Program.Main(args);
Assert.AreEqual(1, result);

string expected = "already produced newsfiles for this version";
Assert.IsTrue(c.Output.Contains(expected));
}
}
}

0 comments on commit 72c12b6

Please sign in to comment.