Skip to content

Commit

Permalink
Unit test enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
halim-lee committed Dec 2, 2021
1 parent 13c5c36 commit a28bae0
Show file tree
Hide file tree
Showing 2 changed files with 482 additions and 52 deletions.
18 changes: 9 additions & 9 deletions utils/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestGetDiscoveryClient(t *testing.T) {
logger := zap.New()
logf.SetLogger(logger)

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand All @@ -67,7 +67,7 @@ func TestCreateOrUpdate(t *testing.T) {
logf.SetLogger(logger)
serviceAccount := &corev1.ServiceAccount{ObjectMeta: defaultMeta}

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand All @@ -88,7 +88,7 @@ func TestDeleteResources(t *testing.T) {
logger := zap.New()
logf.SetLogger(logger)

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestGetOpConfigMap(t *testing.T) {
},
}

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand All @@ -167,7 +167,7 @@ func TestManageError(t *testing.T) {
logf.SetLogger(logger)
err := fmt.Errorf("test-error")

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand All @@ -188,7 +188,7 @@ func TestManageSuccess(t *testing.T) {
logger := zap.New()
logf.SetLogger(logger)

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand All @@ -207,7 +207,7 @@ func TestIsGroupVersionSupported(t *testing.T) {
logger := zap.New()
logf.SetLogger(logger)

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
objs, s := []runtime.Object{runtimecomponent}, scheme.Scheme
s.AddKnownTypes(appstacksv1beta2.GroupVersion, runtimecomponent)
cl := fakeclient.NewFakeClient(objs...)
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestIsGroupVersionSupported(t *testing.T) {
func testGetSvcTLSValues(t *testing.T) {
// Configure the runtime component

runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
expose := true
runtimecomponent.Spec.Expose = &expose
runtimecomponent.Spec.Service = &appstacksv1beta2.RuntimeComponentService{
Expand Down Expand Up @@ -283,7 +283,7 @@ func testGetSvcTLSValues(t *testing.T) {
// testGetRouteTLSValues test the function GetRouteTLSValues in reconciler.go.
func testGetRouteTLSValues(t *testing.T) {
// Configure the rumtime component
runtimecomponent := createRuntimeComponent(name, namespace, spec)
runtimecomponent := createRuntimeComponent(objMeta, spec)
terminationPolicy := routev1.TLSTerminationReencrypt
secretRefName := "my-app-route-tls"
runtimecomponent.Spec.Expose = &expose
Expand Down
Loading

0 comments on commit a28bae0

Please sign in to comment.