Skip to content

Commit

Permalink
Fix tests failing with badge-plugin 2.5 onwards (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
strangelookingnerd authored Nov 13, 2024
1 parent 0b30546 commit adf06de
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import hudson.model.Item;
import hudson.model.Result;
import hudson.model.User;
import hudson.util.VersionNumber;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -478,7 +479,15 @@ public void testBadgeMigration() throws Exception {

BadgeSummaryAction badgeSummaryAction = b.getAction(BadgeSummaryAction.class);
assertNotNull(badgeSummaryAction);
assertEquals("/plugin/badge/images/info.gif", badgeSummaryAction.getIcon());

VersionNumber badgePluginVersion =
j.getPluginManager().getPlugin("badge").getVersionNumber();

if (badgePluginVersion.isNewerThanOrEqualTo(new VersionNumber("2.5"))) {
assertEquals("symbol-information-circle", badgeSummaryAction.getIcon());
} else {
assertEquals("/plugin/badge/images/info.gif", badgeSummaryAction.getIcon());
}
assertEquals("<b>summaryText</b>", badgeSummaryAction.getText());
}

Expand All @@ -487,15 +496,28 @@ public void testBadgeMigration() throws Exception {
FreeStyleBuild b = j.assertBuildStatusSuccess(p.scheduleBuild2(0));
assertNotNull(b);

VersionNumber badgePluginVersion =
j.getPluginManager().getPlugin("badge").getVersionNumber();

BadgeAction badgeAction = b.getAction(BadgeAction.class);
assertNotNull(badgeAction);
assertEquals("/plugin/badge/images/success.gif", badgeAction.getIcon());

if (badgePluginVersion.isNewerThanOrEqualTo(new VersionNumber("2.5"))) {
assertEquals("symbol-status-blue", badgeAction.getIcon());
} else {
assertEquals("/plugin/badge/images/success.gif", badgeAction.getIcon());
}
assertEquals("shortText", badgeAction.getText());
assertEquals("https://jenkins.io/", badgeAction.getLink());

BadgeSummaryAction badgeSummaryAction = b.getAction(BadgeSummaryAction.class);
assertNotNull(badgeSummaryAction);
assertEquals("/plugin/badge/images/info.gif", badgeSummaryAction.getIcon());

if (badgePluginVersion.isNewerThanOrEqualTo(new VersionNumber("2.5"))) {
assertEquals("symbol-information-circle", badgeSummaryAction.getIcon());
} else {
assertEquals("/plugin/badge/images/info.gif", badgeSummaryAction.getIcon());
}
assertEquals("<b>summaryText</b>", badgeSummaryAction.getText());
}
}
Expand Down

0 comments on commit adf06de

Please sign in to comment.