Skip to content

Commit

Permalink
Post-merge clean-up:
Browse files Browse the repository at this point in the history
* 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
jan-molak committed Feb 22, 2014
1 parent 97fdac9 commit 62745f3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>build-monitor-plugin</artifactId>
<version>1.2-SNAPSHOT</version>
<version>1.3-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Build Monitor View</name>
Expand Down Expand Up @@ -68,7 +68,7 @@
</os>
</activation>
<properties>
<npm-executable>C:\Program Files\nodejs\npm.cmd</npm-executable>
<npm-executable>npm.cmd</npm-executable>
</properties>
</profile>
</profiles>
Expand Down
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;
}
}

0 comments on commit 62745f3

Please sign in to comment.