diff --git a/pkg/sync/kubernetes/kubernetes_sync.go b/pkg/sync/kubernetes/kubernetes_sync.go index ea203c5cf..df444cee4 100644 --- a/pkg/sync/kubernetes/kubernetes_sync.go +++ b/pkg/sync/kubernetes/kubernetes_sync.go @@ -312,7 +312,13 @@ func k8sClusterConfig() (*rest.Config, error) { return clusterConfig, nil } -func NewK8sSync(logger *logger.Logger, uri string, providerArgs sync.ProviderArgs, reader client.Reader, dynamic dynamic.Interface) *Sync { +func NewK8sSync( + logger *logger.Logger, + uri string, + providerArgs sync.ProviderArgs, + reader client.Reader, + dynamic dynamic.Interface, +) *Sync { return &Sync{ logger: logger, URI: uri, diff --git a/pkg/sync/kubernetes/kubernetes_sync_test.go b/pkg/sync/kubernetes/kubernetes_sync_test.go index 7ea7d4df5..013b80def 100644 --- a/pkg/sync/kubernetes/kubernetes_sync_test.go +++ b/pkg/sync/kubernetes/kubernetes_sync_test.go @@ -664,7 +664,6 @@ func TestSync_ReSync(t *testing.T) { if err := tt.k.ReSync(context.TODO(), dataChannel); err != nil { t.Errorf("Unexpected error: %v", e) } - }() i := tt.countMsg for i > 0 { @@ -813,20 +812,36 @@ func Test_NewK8sSync(t *testing.T) { t.Errorf("Unexpected error: %v", err) } const uri = "myURI" - args := map[string]string{"myArg": "myVal"} + log := logger.NewLogger(l, true) + const key, value = "myKey", "myValue" + args := map[string]string{key: value} rc := newFakeReadClient() - fc := fake.NewSimpleDynamicClient(runtime.NewScheme()) + dc := fake.NewSimpleDynamicClient(runtime.NewScheme()) k := NewK8sSync( - logger.NewLogger(l, true), + log, uri, args, rc, - fc, + dc, ) if k == nil { t.Errorf("Object not initialized properly") } - // TODO complete asserts + if k.URI != uri { + t.Errorf("Object not initialized with the right URI") + } + if k.logger != log { + t.Errorf("Object not initialized with the right logger") + } + if k.providerArgs[key] != value { + t.Errorf("Object not initialized with the right arguments") + } + if k.readClient != rc { + t.Errorf("Object not initialized with the right K8s client") + } + if k.dynamicClient != dc { + t.Errorf("Object not initialized with the right K8s dynamic client") + } } func newFakeReadClient(objs ...client.Object) client.Client {