Skip to content

Commit

Permalink
add more assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Giovanni Liva <[email protected]>
  • Loading branch information
thisthat committed Mar 7, 2023
1 parent 6f3062d commit f919d00
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
8 changes: 7 additions & 1 deletion pkg/sync/kubernetes/kubernetes_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 21 additions & 6 deletions pkg/sync/kubernetes/kubernetes_sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f919d00

Please sign in to comment.