Skip to content

Commit a86ed62

Browse files
committed
improve fake client
1 parent ac65cd5 commit a86ed62

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pkg/operator/configobserver/config_observer_controller_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package configobserver
33
import (
44
"context"
55
"fmt"
6+
"k8s.io/apimachinery/pkg/util/json"
67
"reflect"
78
"strings"
89
"testing"
@@ -70,6 +71,16 @@ func (c *fakeOperatorClient) ApplyOperatorSpec(ctx context.Context, fieldManager
7071
}
7172

7273
func (c *fakeOperatorClient) ApplyOperatorStatus(ctx context.Context, fieldManager string, applyConfiguration *applyoperatorv1.OperatorStatusApplyConfiguration) (err error) {
74+
applyJSON, err := json.Marshal(applyConfiguration)
75+
if err != nil {
76+
return fmt.Errorf("marshal failure: %w", err)
77+
}
78+
status := &operatorv1.OperatorStatus{}
79+
if err := json.Unmarshal(applyJSON, status); err != nil {
80+
return fmt.Errorf("unmarshal failure: %w", err)
81+
}
82+
c.status = status
83+
7384
return nil
7485
}
7586

0 commit comments

Comments
 (0)