Skip to content

Commit

Permalink
Test case with newlines #132
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Sep 2, 2019
1 parent 8f69e3b commit 23bbefc
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 54 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Generic Webhook Plugin Changelog
Changelog of Generic Webhook Plugin.
## Unreleased
### GitHub [#130](https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/130) Replay jenkins pipeline job using generic webhook trigger *question*

**Documenting replay pipeline #130**


[8f69e3b659a5ee3](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/8f69e3b659a5ee3) Tomas Bjerre *2019-08-27 17:07:58*


## 1.57 (2019-08-20 18:10:41)
### No issue

Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/jenkinsci/plugins/gwt/RendererTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ public void testThatEmptyExprAndEmptyTextIsMatched() {
.isTrue();
}

@Test
public void testThatIsMatchingWorksWithNewlines() {
regexpFilterText = "firstsecondthird";
regexpFilterExpression = "^(?!.*(second)).*";
final boolean actual = isMatching(regexpFilterText, regexpFilterExpression);

assertThat(actual) //
.isFalse();
}

@Test
public void testThatIsMatchingWorksDevelopCorrectUser() {
regexpFilterText = "refs/heads/develop tomabje";
Expand Down
10 changes: 9 additions & 1 deletion src/test/java/org/jenkinsci/plugins/gwt/bdd/Stepdefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,22 @@ private boolean isMatching(final boolean expected) {
final String renderedRegexpFilterText = renderedText(resolvedVariables);
final boolean isMatching =
Renderer.isMatching(renderedRegexpFilterText, featureState.getRegexpFilterExpression());
if (!isMatching && expected || isMatching && !expected) {
if (!isMatching && expected) {
fail(
"Text: \""
+ renderedRegexpFilterText
+ "\" does not match \""
+ featureState.getRegexpFilterExpression()
+ "\"");
}
if (isMatching && !expected) {
fail(
"Text: \""
+ renderedRegexpFilterText
+ "\" does match \""
+ featureState.getRegexpFilterExpression()
+ "\"");
}
return isMatching;
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,41 @@ Feature: It should be possible to use variables resolved from post content.
| text | expression |
| $committer_name | tomas |
Then the job is not triggered


Scenario: Matched content contains newlines

Given the following generic variables are configured:
| variable | expression | expressionType | defaultValue | regexpFilter |
| messageFiltered | $.message | JSONPath | | [\r\n] |

When received post content is:
"""
{
"message": "first abc\nabc second def\n abc third"
}
"""

Then variables are resolved to:
| variable | value |
| messageFiltered | first abcabc second def abc third |

Given filter is configured with:
| text | expression |
| $messageFiltered | ^(?!.*(first)).* |
Then the job is not triggered

Given filter is configured with:
| text | expression |
| $messageFiltered | ^(?!.*(second)).* |
Then the job is not triggered

Given filter is configured with:
| text | expression |
| $messageFiltered | ^(?!.*(third)).* |
Then the job is not triggered

Given filter is configured with:
| text | expression |
| $messageFiltered | ^(?!.*(fourth)).* |
Then the job is triggered

0 comments on commit 23bbefc

Please sign in to comment.