public async Task Run_uses_configured_parser_setting_02() { // ARRANGE var config = ChangeLogConfigurationLoader.GetDefaultConfiguration(); config.Parser.Mode = ChangeLogConfiguration.ParserMode.Strict; var sut = new ParseCommitsTask(m_Logger, config); var versionChangeLog = GetSingleVersionChangeLog("1.2.3", TestGitIds.Id1); { versionChangeLog.Add( GetGitCommit(commitMessage: "feat: Some Description\r\n" + "\r\n" + "\r\n" + "Message Body\r\n") ); } // ACT var result = await sut.RunAsync(new ApplicationChangeLog() { versionChangeLog }); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); Assert.NotNull(versionChangeLog.AllEntries); Assert.Empty(versionChangeLog.AllEntries); }
public async Task Run_uses_configured_parser_setting_02() { // ARRANGE var config = ChangeLogConfigurationLoader.GetDefaultConfiguration(); config.Parser.Mode = ChangeLogConfiguration.ParserMode.Strict; var repo = new Mock <IGitRepository>(MockBehavior.Strict); repo .Setup(x => x.GetCommits(null, It.IsAny <GitId>())) .Returns(new[] { // commit message is only parsable in "Loose" mode GetGitCommit(commitMessage: "feat: Some Description\r\n" + "\r\n" + "\r\n" + "Message Body\r\n"), }); var sut = new ParseCommitsTask(m_Logger, config, repo.Object); var versionChangeLog = GetSingleVersionChangeLog("1.2.3", "01"); var changelog = new ApplicationChangeLog() { versionChangeLog }; // ACT var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); Assert.NotNull(versionChangeLog.AllEntries); Assert.Empty(versionChangeLog.AllEntries); }
public async Task Run_ignores_unparsable_commit_messages() { // ARRANGE var repo = new Mock <IGitRepository>(MockBehavior.Strict); repo .Setup(x => x.GetCommits(null, It.IsAny <GitId>())) .Returns(new[] { GetGitCommit(commitMessage: "Not a conventional commit"), }); var sut = new ParseCommitsTask(m_Logger, m_DefaultConfiguration, repo.Object); var versionChangeLog = GetSingleVersionChangeLog("1.2.3", "01"); var changelog = new ApplicationChangeLog() { versionChangeLog }; // ACT var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); Assert.NotNull(versionChangeLog.AllEntries); Assert.Empty(versionChangeLog.AllEntries); }
public async Task Run_adds_the_expected_entries_if_a_previous_version_exists() { // ARRANGE var repo = new Mock <IGitRepository>(MockBehavior.Strict); repo .Setup(x => x.GetCommits(null, new GitId("01"))) .Returns(Array.Empty <GitCommit>()); repo .Setup(x => x.GetCommits(new GitId("01"), new GitId("02"))) .Returns(new[] { GetGitCommit("ab", "feat: Some new feature"), GetGitCommit("cd", "fix: Some bugfix"), }); var sut = new ParseCommitsTask(m_Logger, m_DefaultConfiguration, repo.Object); var versionChangeLog1 = GetSingleVersionChangeLog("1.2.3", "01"); var versionChangeLog2 = GetSingleVersionChangeLog("2.4.5", "02"); var changelog = new ApplicationChangeLog() { versionChangeLog1, versionChangeLog2 }; // ACT var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); repo.Verify(x => x.GetCommits(null, It.IsAny <GitId>()), Times.Once); repo.Verify(x => x.GetCommits(It.IsAny <GitId>(), It.IsAny <GitId>()), Times.Once); Assert.NotNull(versionChangeLog1.AllEntries); Assert.Empty(versionChangeLog1.AllEntries); Assert.NotNull(versionChangeLog2.AllEntries); Assert.Equal(2, versionChangeLog2.AllEntries.Count()); { var entry = Assert.Single(versionChangeLog2.AllEntries, e => e.Type.Equals(CommitType.Feature)); Assert.Equal(new GitId("ab"), entry.Commit); Assert.Null(entry.Scope); Assert.Equal("Some new feature", entry.Summary); Assert.NotNull(entry.Body); Assert.Empty(entry.Body); } { var entry = Assert.Single(versionChangeLog2.AllEntries, e => e.Type.Equals(CommitType.BugFix)); Assert.Equal(new GitId("cd"), entry.Commit); Assert.Null(entry.Scope); Assert.Equal("Some bugfix", entry.Summary); Assert.NotNull(entry.Body); Assert.Empty(entry.Body); } }
public async Task Run_does_nothing_for_empty_changelog() { // ARRANGE var sut = new ParseCommitsTask(m_Logger, m_DefaultConfiguration); // ACT var changelog = new ApplicationChangeLog(); var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Skipped, result); }
public async Task Run_adds_the_expected_entries_if_a_previous_version_exists() { // ARRANGE var sut = new ParseCommitsTask(m_Logger, m_DefaultConfiguration); var versionChangeLog1 = GetSingleVersionChangeLog("1.2.3", TestGitIds.Id1); var versionChangeLog2 = GetSingleVersionChangeLog("2.4.5", TestGitIds.Id2); { versionChangeLog2.Add( GetGitCommit(TestGitIds.Id1, "feat: Some new feature") ); versionChangeLog2.Add( GetGitCommit(TestGitIds.Id2, "fix: Some bugfix") ); } var changelog = new ApplicationChangeLog() { versionChangeLog1, versionChangeLog2 }; // ACT var result = await sut.RunAsync(changelog); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); Assert.NotNull(versionChangeLog1.AllEntries); Assert.Empty(versionChangeLog1.AllEntries); Assert.NotNull(versionChangeLog2.AllEntries); Assert.Equal(2, versionChangeLog2.AllEntries.Count()); { var entry = Assert.Single(versionChangeLog2.AllEntries, e => e.Type.Equals(CommitType.Feature)); Assert.Equal(TestGitIds.Id1, entry.Commit); Assert.Null(entry.Scope); Assert.Equal("Some new feature", entry.Summary); Assert.NotNull(entry.Body); Assert.Empty(entry.Body); } { var entry = Assert.Single(versionChangeLog2.AllEntries, e => e.Type.Equals(CommitType.BugFix)); Assert.Equal(TestGitIds.Id2, entry.Commit); Assert.Null(entry.Scope); Assert.Equal("Some bugfix", entry.Summary); Assert.NotNull(entry.Body); Assert.Empty(entry.Body); } }
public async Task Run_ignores_unparsable_commit_messages() { // ARRANGE var sut = new ParseCommitsTask(m_Logger, m_DefaultConfiguration); var versionChangeLog = GetSingleVersionChangeLog("1.2.3", TestGitIds.Id1); { versionChangeLog.Add( GetGitCommit(commitMessage: "Not a conventional commit") ); } // ACT var result = await sut.RunAsync(new ApplicationChangeLog() { versionChangeLog }); // ASSERT Assert.Equal(ChangeLogTaskResult.Success, result); Assert.NotNull(versionChangeLog.AllEntries); Assert.Empty(versionChangeLog.AllEntries); }