@@ -119,18 +119,17 @@ func TestEnsureTrustedCABundleConfigMap(t *testing.T) {
119119 // When the managed label (app=external-secrets) is removed from the ConfigMap,
120120 // the object falls out of the label-filtered cache. The cached Exists() returns
121121 // false, Create() fails with AlreadyExists, and the controller must patch only
122- // the metadata (labels/annotations) via the uncached client, leaving
123- // CNO-managed Data/BinaryData untouched.
124- name : "Create returns AlreadyExists (label-filtered cache miss): uncached client patches metadata" ,
122+ // the metadata (labels/annotations), leaving CNO-managed Data/BinaryData untouched.
123+ name : "Create returns AlreadyExists (label-filtered cache miss): patches metadata to restore labels" ,
125124 resourceMetadata : testResourceMetadata (commontest .TestExternalSecretsConfig ()),
126- preReq : func (_ * Reconciler , cached * fakes.FakeCtrlClient , uncached * fakes.FakeCtrlClient ) {
125+ preReq : func (_ * Reconciler , cached * fakes.FakeCtrlClient , _ * fakes.FakeCtrlClient ) {
127126 cached .ExistsCalls (func (_ context.Context , _ types.NamespacedName , _ client.Object ) (bool , error ) {
128127 return false , nil
129128 })
130129 cached .CreateCalls (func (_ context.Context , _ client.Object , _ ... client.CreateOption ) error {
131130 return apierrors .NewAlreadyExists (schema.GroupResource {Resource : "configmaps" }, trustedCABundleConfigMapName )
132131 })
133- uncached .PatchCalls (func (_ context.Context , obj client.Object , patch client.Patch , _ ... client.PatchOption ) error {
132+ cached .PatchCalls (func (_ context.Context , obj client.Object , patch client.Patch , _ ... client.PatchOption ) error {
134133 cm , ok := obj .(* corev1.ConfigMap )
135134 if ! ok {
136135 t .Errorf ("expected ConfigMap, got %T" , obj )
@@ -178,16 +177,16 @@ func TestEnsureTrustedCABundleConfigMap(t *testing.T) {
178177 wantErr : "failed to create external-secrets/external-secrets-trusted-ca-bundle trusted CA bundle ConfigMap resource: test client error" ,
179178 },
180179 {
181- name : "uncached Patch fails after AlreadyExists from Create" ,
180+ name : "Patch fails after AlreadyExists from Create" ,
182181 resourceMetadata : testResourceMetadata (commontest .TestExternalSecretsConfig ()),
183- preReq : func (_ * Reconciler , cached * fakes.FakeCtrlClient , uncached * fakes.FakeCtrlClient ) {
182+ preReq : func (_ * Reconciler , cached * fakes.FakeCtrlClient , _ * fakes.FakeCtrlClient ) {
184183 cached .ExistsCalls (func (_ context.Context , _ types.NamespacedName , _ client.Object ) (bool , error ) {
185184 return false , nil
186185 })
187186 cached .CreateCalls (func (_ context.Context , _ client.Object , _ ... client.CreateOption ) error {
188187 return apierrors .NewAlreadyExists (schema.GroupResource {Resource : "configmaps" }, trustedCABundleConfigMapName )
189188 })
190- uncached .PatchCalls (func (_ context.Context , _ client.Object , _ client.Patch , _ ... client.PatchOption ) error {
189+ cached .PatchCalls (func (_ context.Context , _ client.Object , _ client.Patch , _ ... client.PatchOption ) error {
191190 return commontest .ErrTestClient
192191 })
193192 },
@@ -249,10 +248,10 @@ func TestEnsureTrustedCABundleConfigMap(t *testing.T) {
249248 if tt .wantCreate && cached .CreateCallCount () == 0 {
250249 t .Error ("expected Create to be called, but it wasn't" )
251250 }
252- if tt .wantPatch && cached .PatchCallCount () == 0 && uncached . PatchCallCount () == 0 {
253- t .Error ("expected Patch to be called (on cached or uncached client) , but it wasn't" )
251+ if tt .wantPatch && cached .PatchCallCount () == 0 {
252+ t .Error ("expected Patch to be called, but it wasn't" )
254253 }
255- if ! tt .wantPatch && ( cached .PatchCallCount () > 0 || uncached . PatchCallCount () > 0 ) {
254+ if ! tt .wantPatch && cached .PatchCallCount () > 0 {
256255 t .Error ("expected no Patch call, but one was made" )
257256 }
258257 })
0 commit comments