Skip to content

Commit

Permalink
Fix JENKINS-38668
Browse files Browse the repository at this point in the history
  • Loading branch information
slide committed Jan 27, 2017
1 parent 262f3d2 commit f7b7652
Showing 1 changed file with 29 additions and 0 deletions.
Expand Up @@ -242,6 +242,27 @@ public void testShouldPrintDefaultMessageWhenNoChanges()
+ "\n", contentStr);
}

@Test
public void testShouldPrintDefaultMessageWhenNoChangeSets()
throws Exception {
AbstractBuild failureBuild = createBuild(Result.FAILURE, 41, "[DEFECT-666] Changes for a failed build.");

AbstractBuild currentBuild = createBuildWithNoChangeSets(Result.SUCCESS, 42);
when(currentBuild.getPreviousBuild()).thenReturn(failureBuild);
when(failureBuild.getNextBuild()).thenReturn(currentBuild);

String contentStr = content.evaluate(currentBuild, listener, ChangesSinceLastSuccessfulBuildMacro.MACRO_NAME);

Assert.assertEquals("Changes for Build #41\n"
+ "[Ash Lux] [DEFECT-666] Changes for a failed build.\n"
+ "\n"
+ "\n"
+ "Changes for Build #42\n"
+ ChangesSinceLastBuildMacro.DEFAULT_DEFAULT_VALUE
+ "\n", contentStr);
}


@Test
public void testShouldPrintMessageWhenNoChanges()
throws Exception {
Expand Down Expand Up @@ -270,6 +291,14 @@ private AbstractBuild createBuildWithNoChanges(Result result, int buildNumber) {
when(build.getChangeSet()).thenReturn(changes1);
when(build.getChangeSets()).thenReturn(Collections.singletonList(changes1));
when(build.getNumber()).thenReturn(buildNumber);
return build;
}

private AbstractBuild createBuildWithNoChangeSets(Result result, int buildNumber) {
AbstractBuild build = mock(AbstractBuild.class);
when(build.getResult()).thenReturn(result);
when(build.getChangeSets()).thenReturn(Collections.EMPTY_LIST);
when(build.getNumber()).thenReturn(buildNumber);

return build;
}
Expand Down

0 comments on commit f7b7652

Please sign in to comment.