Skip to content

Commit

Permalink
Merge pull request jenkinsci#1073 from raghavgarg098/ImprooveTests
Browse files Browse the repository at this point in the history
Improving a unit test in GitSCMTest
  • Loading branch information
MarkEWaite authored Apr 18, 2021
2 parents 051f192 + 8f149fb commit 7b8457d
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/test/java/hudson/plugins/git/GitSCMTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3202,17 +3202,7 @@ public void testCommitMessageIsPrintedToLogs() throws Exception {
sampleRepo.git("commit", "--all", "--message=test commit");
FreeStyleProject p = setupSimpleProject("master");
Run<?,?> run = rule.buildAndAssertSuccess(p);
TaskListener mockListener = Mockito.mock(TaskListener.class);
Mockito.when(mockListener.getLogger()).thenReturn(Mockito.spy(StreamTaskListener.fromStdout().getLogger()));

p.getScm().checkout(run, new Launcher.LocalLauncher(listener),
new FilePath(run.getRootDir()).child("tmp-" + "master"),
mockListener, null, SCMRevisionState.NONE);

ArgumentCaptor<String> logCaptor = ArgumentCaptor.forClass(String.class);
verify(mockListener.getLogger(), atLeastOnce()).println(logCaptor.capture());
List<String> values = logCaptor.getAllValues();
assertThat(values, hasItem("Commit message: \"test commit\""));
rule.waitForMessage("Commit message: \"test commit\"", run);
}

/**
Expand Down

0 comments on commit 7b8457d

Please sign in to comment.