go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/sdk/selector/in_test.go (about) 1 /* 2 3 Copyright (c) 2023 - Present. Will Charczuk. All rights reserved. 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file at the root of the repository. 5 6 */ 7 8 package selector 9 10 import ( 11 "testing" 12 13 . "go.charczuk.com/sdk/assert" 14 ) 15 16 func Test_In(t *testing.T) { 17 18 valid := Labels{ 19 "foo": "far", 20 "moo": "lar", 21 } 22 valid2 := Labels{ 23 "foo": "bar", 24 "moo": "lar", 25 } 26 missing := Labels{ 27 "loo": "mar", 28 "moo": "lar", 29 } 30 invalid := Labels{ 31 "foo": "mar", 32 "moo": "lar", 33 } 34 35 selector := In{Key: "foo", Values: []string{"bar", "far"}} 36 ItsEqual(t, true, selector.Matches(valid)) 37 ItsEqual(t, true, selector.Matches(valid2)) 38 ItsEqual(t, false, selector.Matches(missing)) 39 ItsEqual(t, false, selector.Matches(invalid)) 40 41 ItsEqual(t, "foo in (bar, far)", selector.String()) 42 }