github.com/blend/go-sdk@v1.20220411.3/selector/in_test.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package selector
     9  
    10  import (
    11  	"testing"
    12  
    13  	"github.com/blend/go-sdk/assert"
    14  )
    15  
    16  func TestIn(t *testing.T) {
    17  	assert := assert.New(t)
    18  
    19  	valid := Labels{
    20  		"foo": "far",
    21  		"moo": "lar",
    22  	}
    23  	valid2 := Labels{
    24  		"foo": "bar",
    25  		"moo": "lar",
    26  	}
    27  	missing := Labels{
    28  		"loo": "mar",
    29  		"moo": "lar",
    30  	}
    31  	invalid := Labels{
    32  		"foo": "mar",
    33  		"moo": "lar",
    34  	}
    35  
    36  	selector := In{Key: "foo", Values: []string{"bar", "far"}}
    37  	assert.True(selector.Matches(valid))
    38  	assert.True(selector.Matches(valid2))
    39  	assert.False(selector.Matches(missing))
    40  	assert.False(selector.Matches(invalid))
    41  
    42  	assert.Equal("foo in (bar, far)", selector.String())
    43  }