diff --git a/utils/list.go b/utils/list.go index 2e273f36..e6a259a6 100644 --- a/utils/list.go +++ b/utils/list.go @@ -7,16 +7,16 @@ import ( // StringsIsSubset checks that subset is strict subset of full, and returns // error formatted with errorFmt otherwise func StringsIsSubset(subset []string, full []string, errorFmt string) error { - for checked := range subset { + for _, checked := range subset { found := false - for s := range full { + for _, s := range full { if checked == s { found = true break } } if !found { - return fmt.Errorf(errorFmt, checked, full) + return fmt.Errorf(errorFmt, checked) } } return nil diff --git a/utils/list_test.go b/utils/list_test.go index 8bcf23da..0fe335b9 100644 --- a/utils/list_test.go +++ b/utils/list_test.go @@ -7,10 +7,12 @@ import ( type ListSuite struct { } +var _ = Suite(&ListSuite{}) + func (s *ListSuite) TestStringsIsSubset(c *C) { err := StringsIsSubset([]string{"a", "b"}, []string{"a", "b", "c"}, "[%s]") c.Assert(err, IsNil) err = StringsIsSubset([]string{"b", "a"}, []string{"b", "c"}, "[%s]") - c.Assert(err, ErrorMatches, "[a]") + c.Assert(err, ErrorMatches, "\\[a\\]") }