mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-12 04:08:25 +00:00
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package helpers
|
|
|
|
import (
|
|
"reflect"
|
|
"testing"
|
|
|
|
operatorv1 "open-cluster-management.io/api/operator/v1"
|
|
)
|
|
|
|
func TestFilterClusterAnnotations(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
annotations map[string]string
|
|
want map[string]string
|
|
}{
|
|
{
|
|
name: "empty annotations",
|
|
annotations: map[string]string{},
|
|
want: map[string]string{},
|
|
},
|
|
{
|
|
name: "no cluster annotations",
|
|
annotations: map[string]string{
|
|
"foo": "bar",
|
|
"baz": "qux",
|
|
},
|
|
want: map[string]string{},
|
|
},
|
|
{
|
|
name: "one cluster annotation",
|
|
annotations: map[string]string{
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "foo": "bar",
|
|
"baz": "qux",
|
|
},
|
|
want: map[string]string{
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "foo": "bar",
|
|
},
|
|
},
|
|
{
|
|
name: "multiple cluster annotations",
|
|
annotations: map[string]string{
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "foo": "bar",
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "baz": "qux",
|
|
"quux": "corge",
|
|
},
|
|
want: map[string]string{
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "foo": "bar",
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "baz": "qux",
|
|
},
|
|
},
|
|
{
|
|
name: "all annotations are cluster annotations",
|
|
annotations: map[string]string{
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "foo": "bar",
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "baz": "qux",
|
|
},
|
|
want: map[string]string{
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "foo": "bar",
|
|
operatorv1.ClusterAnnotationsKeyPrefix + "baz": "qux",
|
|
},
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := FilterClusterAnnotations(tt.annotations); !reflect.DeepEqual(got, tt.want) {
|
|
t.Errorf("FilterClusterAnnotations() = %v, want %v", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|