Skip to content

Commit

Permalink
add a helper to search a list for a pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
cttttt authored and jesseduffield committed Feb 2, 2020
1 parent 75ba219 commit fb156bc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/test/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
"fmt"
"os/exec"
"regexp"
"strings"
"testing"

Expand Down Expand Up @@ -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)
}

0 comments on commit fb156bc

Please sign in to comment.