aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMaxim Epishchev <epishev@garant.ru>2016-04-19 16:58:43 +0300
committerMaxim Epishchev <epishev@garant.ru>2016-04-20 13:54:29 +0300
commitade4a1a1e2fdfac7180cadebd574ffe5bdedd062 (patch)
tree573567f237cd68e1f36e2f9d51412c17fe833281 /src/test
parentf08fe64257973cddea7ca3ae837f5cfe3db7b720 (diff)
downloadbbprb-ade4a1a1e2fdfac7180cadebd574ffe5bdedd062.tar.gz
Available "pullRequestAuthor" env variable (featured from #83)
Env variable "pullRequestAuthor" contain two parts of author: full name of user and short username in format, like: "Some Doo <@somedoo>". Add test for PR build filter: now we can filter also by author: "a:maxvodo" by example.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/BitbucketBuildFilterTest.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/java/BitbucketBuildFilterTest.java b/src/test/java/BitbucketBuildFilterTest.java
index 3b35dbc..3a94c82 100644
--- a/src/test/java/BitbucketBuildFilterTest.java
+++ b/src/test/java/BitbucketBuildFilterTest.java
@@ -142,6 +142,26 @@ public class BitbucketBuildFilterTest {
@Test
@WithoutJenkins
+ public void authorFilter() {
+ BitbucketCause cause = EasyMock.createMock(BitbucketCause.class);
+ EasyMock.expect(cause.getTargetBranch()).andReturn("master").anyTimes();
+ EasyMock.expect(cause.getSourceBranch()).andReturn("feature-master").anyTimes();
+ EasyMock.expect(cause.getPullRequestAuthor()).andReturn("test").anyTimes();
+ EasyMock.replay(cause);
+
+ for(String f : new String[] {"a:test", "a:r:^test", "d: s: a:", "a:", "a:foo a:test"}) {
+ BitbucketBuildFilter filter = BitbucketBuildFilter.InstanceByString(f);
+ assertTrue(filter.approved(cause));
+ }
+
+ for(String f : new String[] {"s:feature-master", "d:master", "s:feature-master d: a:foo", "a:bar"}) {
+ BitbucketBuildFilter filter = BitbucketBuildFilter.InstanceByString(f);
+ assertFalse(filter.approved(cause));
+ }
+ }
+
+ @Test
+ @WithoutJenkins
public void emptyGitSCMFilter() {
BitbucketCause cause = EasyMock.createMock(BitbucketCause.class);
EasyMock.expect(cause.getTargetBranch()).andReturn("master").anyTimes();