-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebhook_test.go
50 lines (42 loc) · 1.08 KB
/
webhook_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"testing"
"github.com/uswitch/vault-webhook/pkg/apis/vaultwebhook.uswitch.com/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func TestFilterBindings(t *testing.T) {
bindings := []v1alpha1.DatabaseCredentialBinding{
v1alpha1.DatabaseCredentialBinding{
ObjectMeta: metav1.ObjectMeta{
Namespace: "foo",
},
},
v1alpha1.DatabaseCredentialBinding{
ObjectMeta: metav1.ObjectMeta{
Namespace: "bah",
},
},
}
bindings = filterBindings(bindings, "foo")
if len(bindings) != 1 {
t.Errorf("should have got one filtered binding, got: %v", len(bindings))
}
}
func TestMatchBindings(t *testing.T) {
bindings := []v1alpha1.DatabaseCredentialBinding{
v1alpha1.DatabaseCredentialBinding{
Spec: v1alpha1.DatabaseCredentialBindingSpec{
ServiceAccount: "foo",
},
},
v1alpha1.DatabaseCredentialBinding{
Spec: v1alpha1.DatabaseCredentialBindingSpec{
ServiceAccount: "bah",
},
},
}
databases := matchBindings(bindings, "bah")
if len(databases) != 1 {
t.Errorf("should have got one database, got: %v", len(databases))
}
}