github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/pkg/labels/mocklabels/mock_test.go (about) 1 package mocklabels_test 2 3 import ( 4 "testing" 5 6 "github.com/caos/orbos/pkg/labels" 7 "github.com/caos/orbos/pkg/labels/mocklabels" 8 ) 9 10 func TestLabelMockTypes(t *testing.T) { 11 12 for _, testcase := range []struct { 13 labelType string 14 typed labels.Labels 15 untyped map[string]string 16 }{{ 17 "Name", 18 mocklabels.Name, 19 mocklabels.NameMap, 20 }, { 21 "ClosedNameSelector", 22 mocklabels.ClosedNameSelector, 23 mocklabels.ClosedNameSelectorMap, 24 }, { 25 "Selectable", 26 mocklabels.Selectable, 27 mocklabels.SelectableMap, 28 }} { 29 typedStruct := labels.MustK8sMap(testcase.typed) 30 31 for k, v := range typedStruct { 32 untypedVal, ok := testcase.untyped[k] 33 if !ok { 34 t.Errorf("%s: key %s is missing in untyped labels", testcase.labelType, k) 35 continue 36 } 37 38 if untypedVal != v { 39 t.Errorf("%s: at key %s, typed value is %s, not %s", testcase.labelType, k, v, untypedVal) 40 } 41 } 42 43 for k := range testcase.untyped { 44 if _, ok := typedStruct[k]; !ok { 45 t.Errorf("%s: key %s is expandable in untyped labels", testcase.labelType, k) 46 } 47 } 48 } 49 }