@@ -437,6 +437,16 @@ var postgresqlList = []struct {
437437 PostgresqlList {},
438438 errors .New ("unexpected end of JSON input" )}}
439439
440+ var annotations = []struct {
441+ in []byte
442+ annotations map [string ]string
443+ err error
444+ }{{
445+ in : []byte (`{"kind": "Postgresql","apiVersion": "acid.zalan.do/v1","metadata": {"name": "acid-testcluster1"}, "spec": {"podAnnotations": {"foo": "bar"},"teamId": "acid", "clone": {"cluster": "team-batman"}}}` ),
446+ annotations : map [string ]string {"foo" : "bar" },
447+ err : nil },
448+ }
449+
440450func mustParseTime (s string ) metav1.Time {
441451 v , err := time .Parse ("15:04" , s )
442452 if err != nil {
@@ -482,6 +492,25 @@ func TestWeekdayTime(t *testing.T) {
482492 }
483493}
484494
495+ func TestClusterAnnotations (t * testing.T ) {
496+ for _ , tt := range annotations {
497+ var cluster Postgresql
498+ err := cluster .UnmarshalJSON (tt .in )
499+ if err != nil {
500+ if tt .err == nil || err .Error () != tt .err .Error () {
501+ t .Errorf ("Unable to marshal cluster with annotations: expected %v got %v" , tt .err , err )
502+ }
503+ continue
504+ }
505+ for k , v := range cluster .Spec .PodAnnotations {
506+ found , expected := v , tt .annotations [k ]
507+ if found != expected {
508+ t .Errorf ("Didn't find correct value for key %v in for podAnnotations: Expected %v found %v" , k , expected , found )
509+ }
510+ }
511+ }
512+ }
513+
485514func TestClusterName (t * testing.T ) {
486515 for _ , tt := range clusterNames {
487516 name , err := extractClusterName (tt .in , tt .inTeam )
0 commit comments