-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Plugin Version brought back to 1.3 * BuildMonitorViewTest is still part of the test suite * Maven no longer assumes that nodejs is installed under C:\Program Files on Windows-based platforms Closes #34, #39
- Loading branch information
Showing
2 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/com/smartcodeltd/jenkinsci/plugins/buildmonitor/BuildMonitorViewTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.smartcodeltd.jenkinsci.plugins.buildmonitor; | ||
|
||
import hudson.util.FormValidation; | ||
import org.apache.commons.lang.StringEscapeUtils; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static com.smartcodeltd.jenkinsci.plugins.buildmonitor.viewmodel.syntacticsugar.Loops.asFollows; | ||
import static hudson.util.FormValidation.Kind.*; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.core.Is.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class BuildMonitorViewTest { | ||
|
||
private BuildMonitorView.Descriptor validator; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
validator = new BuildMonitorView.Descriptor(); | ||
} | ||
|
||
@Test | ||
public void form_validator_should_allow_valid_reg_ex_specifying_what_jobs_to_include() { | ||
for (String regex : asFollows(null, "", ".*", "myproject-.*")) { | ||
assertThat(itShouldAllow(regex), validator.doCheckIncludeRegex(regex).kind, is(OK)); | ||
} | ||
} | ||
|
||
@Test | ||
public void form_validator_should_advise_how_a_regex_could_be_improved() { | ||
FormValidation result = validator.doCheckIncludeRegex(")"); | ||
|
||
assertThat(result.kind, is(ERROR)); | ||
assertThat(htmlDecoded(result.getMessage()), containsString("Unmatched closing ')'")); | ||
} | ||
|
||
private String htmlDecoded(String message) { | ||
return StringEscapeUtils.unescapeHtml(message); | ||
} | ||
|
||
private String itShouldAllow(String regex) { | ||
return "should allow " + regex; | ||
} | ||
} |