extend selector with EXISTS, new tests/some old tests use table-driven style; add Has to Labels interface; enforce Requirement restrictions in constructor

This commit is contained in:
Meir Fischer
2014-08-18 23:41:20 -04:00
parent eb24c997e4
commit 89a9e5e672
4 changed files with 243 additions and 59 deletions

View File

@@ -35,6 +35,23 @@ func TestSetString(t *testing.T) {
// with ",=!" characters in their names.
}
func TestLabelHas(t *testing.T) {
labelHasTests := []struct {
Ls Labels
Key string
Has bool
}{
{Set{"x": "y"}, "x", true},
{Set{"x": ""}, "x", true},
{Set{"x": "y"}, "foo", false},
}
for _, lh := range labelHasTests {
if has := lh.Ls.Has(lh.Key); has != lh.Has {
t.Errorf("%#v.Has(%#v) => %v, expected %v", lh.Ls, lh.Key, has, lh.Has)
}
}
}
func TestLabelGet(t *testing.T) {
ls := Set{"x": "y"}
if ls.Get("x") != "y" {