summaryrefslogtreecommitdiffstats
path: root/pkg/test
diff options
context:
space:
mode:
authorChris Taylor <ctaylorr@gmail.com>2020-02-01 17:10:02 -0500
committerJesse Duffield <jessedduffield@gmail.com>2020-02-02 11:29:22 +1100
commitfb156bcaacf26361a20e89626080c91b9b19e97e (patch)
tree3cbe29f74ae2d4cbeec585958754f9e7da895b9e /pkg/test
parent75ba2196ba365e25bb8888a218536cc8ec713a78 (diff)
add a helper to search a list for a pattern
Diffstat (limited to 'pkg/test')
-rw-r--r--pkg/test/utils.go13
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)
+}