From fb156bcaacf26361a20e89626080c91b9b19e97e Mon Sep 17 00:00:00 2001 From: Chris Taylor Date: Sat, 1 Feb 2020 17:10:02 -0500 Subject: [PATCH] add a helper to search a list for a pattern --- pkg/test/utils.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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) +}