diff options
author | Chris Taylor <ctaylorr@gmail.com> | 2020-02-01 17:10:02 -0500 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-02-02 11:29:22 +1100 |
commit | fb156bcaacf26361a20e89626080c91b9b19e97e (patch) | |
tree | 3cbe29f74ae2d4cbeec585958754f9e7da895b9e /pkg/test | |
parent | 75ba2196ba365e25bb8888a218536cc8ec713a78 (diff) |
add a helper to search a list for a pattern
Diffstat (limited to 'pkg/test')
-rw-r--r-- | pkg/test/utils.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/test/utils.go b/pkg/test/utils.go index 5603fd0ae..b27bdbbab 100644 --- a/pkg/test/utils.go +++ b/pkg/test/utils.go @@ -3,6 +3,7 @@ package test import ( "fmt" "os/exec" + "regexp" "strings" "testing" @@ -43,3 +44,15 @@ func CreateMockCommand(t *testing.T, swappers []*CommandSwapper) func(cmd string return command } } + +func AssertContainsMatch(t *testing.T, strs []string, pattern *regexp.Regexp, message string) { + t.Helper() + + for _, str := range strs { + if pattern.Match([]byte(str)) { + return + } + } + + assert.Fail(t, message) +} |