@@ -13,6 +13,7 @@ import (
1313 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1414 "k8s.io/client-go/tools/record"
1515
16+ configv1 "github.com/openshift/api/config/v1"
1617 osconfigv1 "github.com/openshift/api/config/v1"
1718 fakeconfigclientset "github.com/openshift/client-go/config/clientset/versioned/fake"
1819 "github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
@@ -94,7 +95,7 @@ func TestOperatorStatusProgressing(t *testing.T) {
9495 optr .operandVersions = tc .currentVersion
9596 co := optr .defaultClusterOperator ()
9697 co .Status .Versions = tc .desiredVersion
97- optr .osClient = fakeconfigclientset .NewSimpleClientset (co ) //nolint:staticcheck
98+ optr .osClient = fakeconfigclientset .NewClientset (co )
9899
99100 err := optr .statusProgressing ()
100101 assert .NoError (t , err )
@@ -330,9 +331,9 @@ func TestGetOrCreateClusterOperator(t *testing.T) {
330331 for _ , tc := range testCases {
331332 var osClient * fakeconfigclientset.Clientset
332333 if tc .existingCO != nil {
333- osClient = fakeconfigclientset .NewSimpleClientset (tc .existingCO ) //nolint:staticcheck
334+ osClient = fakeconfigclientset .NewClientset (tc .existingCO )
334335 } else {
335- osClient = fakeconfigclientset .NewSimpleClientset () //nolint:staticcheck
336+ osClient = fakeconfigclientset .NewClientset ()
336337 }
337338 optr := Operator {
338339 osClient : osClient ,
@@ -344,24 +345,36 @@ func TestGetOrCreateClusterOperator(t *testing.T) {
344345 t .Fatalf ("unexpected error: %v" , err )
345346 }
346347
347- normalizeTransitionTimes (co . Status , tc .expectedCO . Status )
348+ normalizeSharedFields (co , tc .expectedCO )
348349
349350 if ! equality .Semantic .DeepEqual (co , tc .expectedCO ) {
350- t .Errorf ("got: %v, expected: %v" , co , tc .expectedCO )
351+ t .Errorf ("got: %+ v, expected: %+ v" , co , tc .expectedCO )
351352 }
352353 }
353354}
354355
355- func normalizeTransitionTimes (got , expected osconfigv1. ClusterOperatorStatus ) {
356+ func normalizeSharedFields (got , expected * configv1. ClusterOperator ) {
356357 now := metav1 .NewTime (time .Now ())
357358
358- for i := range got .Conditions {
359- got .Conditions [i ].LastTransitionTime = now
359+ for i := range got .Status . Conditions {
360+ got .Status . Conditions [i ].LastTransitionTime = now
360361 }
361362
362- for i := range expected .Conditions {
363- expected .Conditions [i ].LastTransitionTime = now
363+ for i := range expected .Status . Conditions {
364+ expected .Status . Conditions [i ].LastTransitionTime = now
364365 }
366+
367+ // The NewClientset will populate these fields on the "got" side, but we don't care about those fields
368+ // So we make them equal
369+ got .Kind = "ClusterOperator"
370+ expected .Kind = "ClusterOperator"
371+
372+ got .APIVersion = "config.openshift.io/v1"
373+ expected .APIVersion = "config.openshift.io/v1"
374+
375+ got .ManagedFields = make ([]metav1.ManagedFieldsEntry , 0 )
376+ expected .ManagedFields = make ([]metav1.ManagedFieldsEntry , 0 )
377+
365378}
366379
367380func TestIsInitializing (t * testing.T ) {
@@ -425,9 +438,9 @@ func TestIsInitializing(t *testing.T) {
425438
426439 var osClient * fakeconfigclientset.Clientset
427440 if tc .existingCO != nil {
428- osClient = fakeconfigclientset .NewSimpleClientset (tc .existingCO ) //nolint:staticcheck
441+ osClient = fakeconfigclientset .NewClientset (tc .existingCO )
429442 } else {
430- osClient = fakeconfigclientset .NewSimpleClientset () //nolint:staticcheck
443+ osClient = fakeconfigclientset .NewClientset ()
431444 }
432445 optr := Operator {
433446 osClient : osClient ,
@@ -487,7 +500,7 @@ func TestIsUpgrading(t *testing.T) {
487500 },
488501 }
489502 optr := Operator {
490- osClient : fakeconfigclientset .NewSimpleClientset (co ),
503+ osClient : fakeconfigclientset .NewClientset (co ),
491504 operandVersions : tc .desiredVersions ,
492505 namespace : "test" ,
493506 }
@@ -566,7 +579,7 @@ func TestUpgradeHasTimedOut(t *testing.T) {
566579 g := NewWithT (t )
567580
568581 optr := Operator {
569- osClient : fakeconfigclientset .NewSimpleClientset (tc .existingCO ),
582+ osClient : fakeconfigclientset .NewClientset (tc .existingCO ),
570583 }
571584
572585 timedOut , err := optr .upgradeHasTimedOut ()
@@ -662,7 +675,7 @@ func TestShouldReportDegraded(t *testing.T) {
662675 g := NewWithT (t )
663676
664677 optr := Operator {
665- osClient : fakeconfigclientset .NewSimpleClientset (tc .existingCO ),
678+ osClient : fakeconfigclientset .NewClientset (tc .existingCO ),
666679 operandVersions : tc .desiredVersions ,
667680 namespace : "test" ,
668681 }
0 commit comments