|
25 | 25 | import java.io.PrintWriter; |
26 | 26 |
|
27 | 27 | import static org.junit.Assert.assertEquals; |
| 28 | +import static org.junit.Assert.assertSame; |
28 | 29 | import static org.junit.Assert.fail; |
29 | 30 | import static org.mockito.Mockito.verify; |
30 | 31 | import static org.mockito.Mockito.when; |
@@ -232,6 +233,33 @@ public void whenUriDoesNotContainUrlNameMustReturnError() throws Exception { |
232 | 233 | log.info("Test succeeded."); |
233 | 234 | } |
234 | 235 |
|
| 236 | + @Test |
| 237 | + public void whenJobBranchNotMatchMustReturnError() throws Exception { |
| 238 | + String[][] test_vals = { |
| 239 | + {null, "master", "true"}, |
| 240 | + {null, "dev", "true"}, |
| 241 | + {"", "master", "true"}, |
| 242 | + {"", "dev", "true"}, |
| 243 | + {"*", "master", "true"}, |
| 244 | + {"*", "dev", "true"}, |
| 245 | + {"dev", "master", "false"}, |
| 246 | + {"dev", "dev", "true"}, |
| 247 | + {"master", "master", "true"}, |
| 248 | + {"master", "dev", "false"}, |
| 249 | + }; |
| 250 | + |
| 251 | + for (int i = 0; i < test_vals.length; ++i) { |
| 252 | + String filter = test_vals[i][0]; |
| 253 | + String ref = test_vals[i][1]; |
| 254 | + boolean ret = Boolean.parseBoolean(test_vals[i][2]); |
| 255 | + |
| 256 | + GogsProjectProperty property = new GogsProjectProperty(null, false, filter); |
| 257 | + assertSame(String.format("branch filter check failed for [%s -> %s]", ref, filter), ret, property.filterBranch(ref)); |
| 258 | + } |
| 259 | + |
| 260 | + log.info("Test succeeded."); |
| 261 | + } |
| 262 | + |
235 | 263 | // |
236 | 264 | // Helper methods |
237 | 265 | // |
|
0 commit comments