Skip to content
Permalink
Browse files

Fix JENKINS-38668

  • Loading branch information
slide committed Jan 27, 2017
1 parent 262f3d2 commit f7b7652e63c7c7a0dbfdde71dd5f75a8d3aeefc0
@@ -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 {
@@ -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;
}

0 comments on commit f7b7652

Please sign in to comment.
You can’t perform that action at this time.