Skip to content

Commit

Permalink
add does-not-contain since it reads better than not-contains
Browse files Browse the repository at this point in the history
  • Loading branch information
Larry Hitchon committed Jun 15, 2018
1 parent be58d2a commit abe333a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion assertion/contains.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func contains(data interface{}, key, value string) (MatchResult, error) {
}
}

func notContains(data interface{}, key, value string) (MatchResult, error) {
func doesNotContain(data interface{}, key, value string) (MatchResult, error) {
m, err := contains(data, key, value)
if err != nil {
return matchError(err)
Expand Down
4 changes: 3 additions & 1 deletion assertion/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ func isMatch(data interface{}, expression Expression) (MatchResult, error) {
case "contains":
return contains(data, key, value)
case "not-contains":
return notContains(data, key, value)
return doesNotContain(data, key, value)
case "does-not-contain":
return doesNotContain(data, key, value)
case "regex":
re, err := regexp.Compile(value)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions assertion/match_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func TestIsMatch(t *testing.T) {
"containsFalseForSubstring": {sliceOfTags, "contains", "oo", "", false},
"containsTrueForSliceOfStrings": {stringSlice, "contains", "One", "", true},
"containsFalseForSliceOfStrings": {stringSlice, "contains", "Three", "", false},
"notContainsFalseForString": {"Foo", "not-contains", "oo", "", false},
"notContainsTrueForString": {"Foo", "not-contains", "aa", "", true},
"notContainsFalseForSlice": {sliceOfTags, "not-contains", "Bar", "", false},
"notContainsTrueForSubstring": {sliceOfTags, "not-contains", "oo", "", true},
"notContainsFalseForString": {"Foo", "does-not-contain", "oo", "", false},
"notContainsTrueForString": {"Foo", "does-not-contain", "aa", "", true},
"notContainsFalseForSlice": {sliceOfTags, "does-not-contain", "Bar", "", false},
"notContainsTrueForSubstring": {sliceOfTags, "does-not-contain", "oo", "", true},
"regexTrueForEndOfString": {"Foo", "regex", "o$", "", true},
"regexFalseForEndOfString": {"Bar", "regex", "o$", "", false},
"regExTrueForBeginningOfString": {"Foo", "regex", "^F", "", true},
Expand Down
4 changes: 2 additions & 2 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
| [ne](#ne) | Not equal |
| [none](#none) | None |
| [not](#not) | Not |
| [not-contains](#not-contains) | Not Contains |
| [does-not-contain](#does-not-contain) | Does Not Contain |
| [not-empty](#not-empty) | Not Empty |
| [not-in](#not-in) | Not In |
| [or](#or) | Or |
Expand Down Expand Up @@ -118,7 +118,7 @@ Attribute is not empty

Attribute contains a substring, or array contains an element

## not-contains
## does-not-contain

Attribute contains a substring, or array contains an element

Expand Down

0 comments on commit abe333a

Please sign in to comment.