github.com/argoproj-labs/argocd-operator@v0.10.0/controllers/argoutil/resource_test.go (about) 1 // Copyright 2019 ArgoCD Operator Developers 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package argoutil 16 17 import ( 18 "reflect" 19 "testing" 20 21 v1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 23 argoproj "github.com/argoproj-labs/argocd-operator/api/v1beta1" 24 "github.com/argoproj-labs/argocd-operator/common" 25 ) 26 27 func TestDefaultAnnotations(t *testing.T) { 28 type args struct { 29 cr *argoproj.ArgoCD 30 } 31 tests := []struct { 32 name string 33 args args 34 want map[string]string 35 }{ 36 { 37 name: "simple annotations", 38 args: args{ 39 &argoproj.ArgoCD{ 40 ObjectMeta: v1.ObjectMeta{ 41 Name: "foo", 42 Namespace: "bar", 43 }, 44 }, 45 }, 46 want: map[string]string{ 47 "argocds.argoproj.io/name": "foo", 48 "argocds.argoproj.io/namespace": "bar", 49 }, 50 }, 51 } 52 for _, tt := range tests { 53 t.Run(tt.name, func(t *testing.T) { 54 if got := common.DefaultAnnotations(tt.args.cr.Name, tt.args.cr.Namespace); !reflect.DeepEqual(got, tt.want) { 55 t.Errorf("DefaultAnnotations() = %v, want %v", got, tt.want) 56 } 57 }) 58 } 59 }