Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
tests(serviceapp): adds status.go coverage (AEROGEAR-8951)
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Murphy committed May 28, 2019
1 parent 80e4ac4 commit 0d93cd9
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions pkg/controller/mobilesecurityserviceapp/status_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package mobilesecurityserviceapp

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"testing"

"sigs.k8s.io/controller-runtime/pkg/reconcile"
mobilesecurityservicev1alpha1 "github.com/aerogear/mobile-security-service-operator/pkg/apis/mobilesecurityservice/v1alpha1"

)

func TestReconcileMobileSecurityServiceApp_updateBindStatusWithInvalidNamespace(t *testing.T) {
type args struct {
instance *mobilesecurityservicev1alpha1.MobileSecurityServiceApp
}
tests := []struct {
name string
args args
wantErr bool
}{
{
name: "should return without an error when updating status",
args: args{
instance: &instance,
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {

objs := []runtime.Object{
tt.args.instance,
}

r := buildReconcileWithFakeClientWithMocks(objs, t)

reqLogger := log.WithValues("Request.Namespace", tt.args.instance.Namespace, "Request.Name", tt.args.instance.Name)

// mock request to simulate Reconcile() being called on an event for a watched resource
req := reconcile.Request{
NamespacedName: types.NamespacedName{
Name: instance.Name,
Namespace: instance.Namespace,
},
}

if err := r.updateBindStatusWithInvalidNamespace(reqLogger, req); (err != nil) != tt.wantErr {
t.Errorf("ReconcileMobileSecurityServiceApp.updateBindStatusWithInvalidNamespace() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}

0 comments on commit 0d93cd9

Please sign in to comment.