Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests #84

Merged
merged 3 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,25 @@ public class GroovyPostbuildRecorderTest {
"import hudson.matrix.MatrixRun;",
"if (manager.buildIsA(MatrixBuild.class)) {",
" // codes for matrix parents.",
" manager.addShortText(\"parent\");",
" manager.addShortText('parent');",
"} else if(manager.buildIsA(MatrixRun)) {",
" // codes for matrix children.",
" manager.addShortText(manager.getEnvVariable(\"axis1\"));",
" manager.addShortText(manager.getEnvVariable('axis1'),",
" 'jenkins-!-color-dark-indigo',",
" 'jenkins-!-color-light-purple',",
" '3px dotted',",
" 'jenkins-!-success-color');",
"} else {",
" // unexpected case.",
" manager.buildFailure();",
"}"
},
'\n');

private static final String SCRIPT_FOR_MATRIX2 = SCRIPT_FOR_MATRIX
.replace("jenkins-!-color-dark-indigo", "jenkins-!-error-color")
.replace("jenkins-!-success-color", "jenkins-!-color-dark-blue");

@Test
public void testMatrixProjectWithParent() throws Exception {
MatrixProject p = j.createProject(MatrixProject.class);
Expand Down Expand Up @@ -120,7 +128,7 @@ public void testMatrixProjectWithoutParent() throws Exception {
p.setAxes(axisList);
p.getPublishersList()
.add(new GroovyPostbuildRecorder(
new SecureGroovyScript(SCRIPT_FOR_MATRIX, true, Collections.<ClasspathEntry>emptyList()),
new SecureGroovyScript(SCRIPT_FOR_MATRIX2, true, Collections.<ClasspathEntry>emptyList()),
2,
false));

Expand Down Expand Up @@ -156,7 +164,9 @@ public void testBehaviorNotAffectWithSucceedingBuildSucceedingScript() throws Ex
p.getPublishersList()
.add(new GroovyPostbuildRecorder(
new SecureGroovyScript(
"manager.addShortText('testing');", true, Collections.<ClasspathEntry>emptyList()),
"manager.addShortText('testing', null, null, null, null);",
true,
Collections.<ClasspathEntry>emptyList()),
behavior, // behavior
false // runForMatrixParent
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ public void usingManager() throws Exception {
assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText());
}

@Test
public void usingManagerAddBadge2Args() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p-addBadge2");
p.setDefinition(new CpsFlowDefinition("manager.addBadge('yellow.gif', 'stuff is broken')", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText());
}

@Test
public void usingManagerInfoBadge() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p-infoBadge");
p.setDefinition(new CpsFlowDefinition("manager.addInfoBadge 'stuff is broken'", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText());
}

@Test
public void usingManagerErrorBadge() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p-errorBadge");
p.setDefinition(new CpsFlowDefinition("manager.addErrorBadge 'stuff is broken'", true));
WorkflowRun b = r.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertEquals("stuff is broken", b.getAction(BadgeAction.class).getText());
}

@Issue("JENKINS-54128")
@Test
public void logContains() throws Exception {
Expand Down