mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-10 06:14:22 +00:00
Fix string search.
This commit is contained in:
+3
-3
@@ -7,16 +7,16 @@ import (
|
|||||||
// StringsIsSubset checks that subset is strict subset of full, and returns
|
// StringsIsSubset checks that subset is strict subset of full, and returns
|
||||||
// error formatted with errorFmt otherwise
|
// error formatted with errorFmt otherwise
|
||||||
func StringsIsSubset(subset []string, full []string, errorFmt string) error {
|
func StringsIsSubset(subset []string, full []string, errorFmt string) error {
|
||||||
for checked := range subset {
|
for _, checked := range subset {
|
||||||
found := false
|
found := false
|
||||||
for s := range full {
|
for _, s := range full {
|
||||||
if checked == s {
|
if checked == s {
|
||||||
found = true
|
found = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
return fmt.Errorf(errorFmt, checked, full)
|
return fmt.Errorf(errorFmt, checked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+3
-1
@@ -7,10 +7,12 @@ import (
|
|||||||
type ListSuite struct {
|
type ListSuite struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ = Suite(&ListSuite{})
|
||||||
|
|
||||||
func (s *ListSuite) TestStringsIsSubset(c *C) {
|
func (s *ListSuite) TestStringsIsSubset(c *C) {
|
||||||
err := StringsIsSubset([]string{"a", "b"}, []string{"a", "b", "c"}, "[%s]")
|
err := StringsIsSubset([]string{"a", "b"}, []string{"a", "b", "c"}, "[%s]")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
err = StringsIsSubset([]string{"b", "a"}, []string{"b", "c"}, "[%s]")
|
err = StringsIsSubset([]string{"b", "a"}, []string{"b", "c"}, "[%s]")
|
||||||
c.Assert(err, ErrorMatches, "[a]")
|
c.Assert(err, ErrorMatches, "\\[a\\]")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user