Skip to content

Commit

Permalink
Added a test for resolve when there is no last job build
Browse files Browse the repository at this point in the history
  • Loading branch information
yashpal2104 committed Oct 25, 2024
1 parent 12a13f6 commit d1206a1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import hudson.model.Job;
Expand Down Expand Up @@ -97,4 +99,13 @@ void testResolveWithNoMatchingParameters() {
String actualParameter = extension.resolve(mockRun, "noMatchingParameters");
assertThat(actualParameter, is("noMatchingParameters"));
}

@Test
void testResolveWhenJobHasNoLastBuild() {
Job<?, ?> job = mock(Job.class);
when(job.getLastBuild()).thenReturn(null);

String parameter = "${buildId}${buildNumber}";
assertEquals("${buildId}${buildNumber}", extension.resolve(job, parameter));
}
}

0 comments on commit d1206a1

Please sign in to comment.