-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override default REGExes used by core lookup_command (#64)
lookup command default matchers can be overriden by passing additional params in the config. in order to support multiple T/D tickets we can use FindAllStringSubmatch to extract all matches and then use map function to de-dupe matches to avoid posting the same ticket more than once Fixes #59
- Loading branch information
Showing
11 changed files
with
141 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
main.production.yml | ||
dist | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package core | ||
|
||
import ( | ||
"testing" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_additionalMatchersNil(t *testing.T) { | ||
lookup_command := LookupCommand{AdditionalMatchers: nil} | ||
assert.NotEmpty(t, lookup_command.GetMatchers()) | ||
} | ||
|
||
func Test_additionalMatchers(t *testing.T) { | ||
additionalMatchers := []string{"([D][0-9]{1,16})", "([D][0-1]{1,16})"} | ||
lookupCommand := LookupCommand{AdditionalMatchers: additionalMatchers} | ||
assert.Contains(t, lookupCommand.GetMatchers(), "([D][0-9]{1,16})") | ||
assert.Contains(t, lookupCommand.GetMatchers(), "([D][0-1]{1,16})") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package utilities | ||
|
||
func UniqueItemsOf(s []string) []string { | ||
unique := make(map[string]bool, len(s)) | ||
uniques := make([]string, len(unique)) | ||
for _, elem := range s { | ||
if len(elem) != 0 { | ||
if !unique[elem] { | ||
uniques = append(uniques, elem) | ||
unique[elem] = true | ||
} | ||
} | ||
} | ||
return uniques | ||
} | ||
|
||
func Contains(slice1 []string, slice2 []string) bool { | ||
slice1Uniques := UniqueItemsOf(slice1) | ||
slice2Uniques := UniqueItemsOf(slice2) | ||
for _, value2 := range slice2Uniques { | ||
var slice2ItemInSlice1 = false | ||
for _, value1 := range slice1Uniques { | ||
if value1 == value2 { | ||
slice2ItemInSlice1 = true | ||
} | ||
} | ||
if !slice2ItemInSlice1 { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters