Browse Source

Add unit test for Has in pkg/labels/labels.go (#7039)

This PR is about adding a unit test for Has in pkg/labels/labels.go.

Signed-off-by: Hu Shuai <hus.fnst@cn.fujitsu.com>
superq/test
Hu Shuai 5 years ago committed by GitHub
parent
commit
002b391dfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 32
      pkg/labels/labels_test.go

32
pkg/labels/labels_test.go

@ -453,3 +453,35 @@ func TestLabels_Compare(t *testing.T) {
testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i) testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i)
} }
} }
func TestLabels_Has(t *testing.T) {
tests := []struct {
input string
expected bool
}{
{
input: "foo",
expected: false,
},
{
input: "aaa",
expected: true,
},
}
labelsSet := Labels{
{
Name: "aaa",
Value: "111",
},
{
Name: "bbb",
Value: "222",
},
}
for i, test := range tests {
got := labelsSet.Has(test.input)
testutil.Equals(t, test.expected, got, "unexpected comparison result for test case %d", i)
}
}

Loading…
Cancel
Save