github.com/doitroot/helm@v3.0.0-beta.3+incompatible/pkg/storage/driver/labels_test.go (about) 1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package driver // import "helm.sh/helm/pkg/storage/driver" 18 19 import ( 20 "testing" 21 ) 22 23 func TestLabelsMatch(t *testing.T) { 24 var tests = []struct { 25 desc string 26 set1 labels 27 set2 labels 28 expect bool 29 }{ 30 { 31 "equal labels sets", 32 labels(map[string]string{"KEY_A": "VAL_A", "KEY_B": "VAL_B"}), 33 labels(map[string]string{"KEY_A": "VAL_A", "KEY_B": "VAL_B"}), 34 true, 35 }, 36 { 37 "disjoint label sets", 38 labels(map[string]string{"KEY_C": "VAL_C", "KEY_D": "VAL_D"}), 39 labels(map[string]string{"KEY_A": "VAL_A", "KEY_B": "VAL_B"}), 40 false, 41 }, 42 } 43 44 for _, tt := range tests { 45 if !tt.set1.match(tt.set2) && tt.expect { 46 t.Fatalf("Expected match '%s'\n", tt.desc) 47 } 48 } 49 }