github.com/operator-framework/operator-lifecycle-manager@v0.30.0/pkg/package-server/provider/labels_test.go (about) 1 package provider 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func TestSetDefaultOsArchLabels(t *testing.T) { 10 type args struct { 11 labels map[string]string 12 } 13 tests := []struct { 14 name string 15 args args 16 expected map[string]string 17 }{ 18 { 19 name: "NoneSet", 20 args: args{labels: map[string]string{}}, 21 expected: map[string]string{ 22 DefaultArchLabel: Supported, 23 DefaultOsLabel: Supported, 24 }, 25 }, 26 { 27 name: "OthersPreserved", 28 args: args{labels: map[string]string{"other": "label"}}, 29 expected: map[string]string{ 30 "other": "label", 31 DefaultArchLabel: Supported, 32 DefaultOsLabel: Supported, 33 }, 34 }, 35 { 36 name: "OsSet", 37 args: args{labels: map[string]string{OsLabelPrefix + ".windows": Supported}}, 38 expected: map[string]string{ 39 DefaultArchLabel: Supported, 40 OsLabelPrefix + ".windows": Supported, 41 }, 42 }, 43 { 44 name: "ArchSet", 45 args: args{labels: map[string]string{ArchLabelPrefix + ".arm": Supported}}, 46 expected: map[string]string{ 47 ArchLabelPrefix + ".arm": Supported, 48 DefaultOsLabel: Supported, 49 }, 50 }, 51 } 52 for _, tt := range tests { 53 t.Run(tt.name, func(t *testing.T) { 54 labels := tt.args.labels 55 setDefaultOsArchLabels(labels) 56 require.Equal(t, tt.expected, labels) 57 }) 58 } 59 }