This repository has been archived by the owner on Dec 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests(serviceapp): adds status.go coverage (AEROGEAR-8951)
- Loading branch information
Damien Murphy
committed
May 28, 2019
1 parent
80e4ac4
commit 0d93cd9
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
} | ||
} |