github.com/argoproj/argo-cd@v1.8.7/controller/sharding/sharding_test.go (about) 1 package sharding 2 3 import ( 4 "testing" 5 6 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" 7 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestGetShardByID_NotEmptyID(t *testing.T) { 12 assert.Equal(t, 0, getShardByID("1", 2)) 13 assert.Equal(t, 1, getShardByID("2", 2)) 14 assert.Equal(t, 0, getShardByID("3", 2)) 15 assert.Equal(t, 1, getShardByID("4", 2)) 16 } 17 18 func TestGetShardByID_EmptyID(t *testing.T) { 19 shard := getShardByID("", 10) 20 assert.Equal(t, 0, shard) 21 } 22 23 func TestGetClusterFilter(t *testing.T) { 24 filter := GetClusterFilter(2, 1) 25 assert.False(t, filter(&v1alpha1.Cluster{ID: "1"})) 26 assert.True(t, filter(&v1alpha1.Cluster{ID: "2"})) 27 assert.False(t, filter(&v1alpha1.Cluster{ID: "3"})) 28 assert.True(t, filter(&v1alpha1.Cluster{ID: "4"})) 29 }