@@ -3,9 +3,9 @@ package permissions
3
3
import (
4
4
"testing"
5
5
6
- "github.com/d4l3k/messagediff"
7
6
"github.com/jetstack/preflight/pkg/agent"
8
7
"github.com/jetstack/preflight/pkg/datagatherer/k8s"
8
+ "github.com/maxatome/go-testdeep/td"
9
9
rbac "k8s.io/api/rbac/v1"
10
10
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
11
"k8s.io/apimachinery/pkg/runtime/schema"
@@ -35,28 +35,24 @@ func TestGenerateRBAC(t *testing.T) {
35
35
},
36
36
},
37
37
expectedClusterRoleBindings : []rbac.ClusterRoleBinding {
38
-
39
38
{
40
39
TypeMeta : metav1.TypeMeta {
41
40
Kind : "ClusterRoleBinding" ,
42
41
APIVersion : "rbac.authorization.k8s.io/v1" ,
43
42
},
44
-
45
43
ObjectMeta : metav1.ObjectMeta {
46
44
Name : "jetstack-secure-agent-ClusterRole-reader" ,
47
45
},
48
-
49
46
Subjects : []rbac.Subject {
50
47
{
51
48
Kind : "ServiceAccount" ,
52
49
Name : "agent" ,
53
50
Namespace : "jetstack-secure" ,
54
51
},
55
52
},
56
-
57
53
RoleRef : rbac.RoleRef {
58
54
Kind : "ClusterRole" ,
59
- Name : "jetstack-secure-agent-secret -reader" ,
55
+ Name : "jetstack-secure-agent-secrets -reader" ,
60
56
APIGroup : "rbac.authorization.k8s.io" ,
61
57
},
62
58
},
@@ -68,9 +64,7 @@ func TestGenerateRBAC(t *testing.T) {
68
64
for _ , input := range testCases {
69
65
got := GenerateRoles (input .dataGatherers )
70
66
toBeTest := GenerateBindings (got )
71
- if diff , equal := messagediff .PrettyDiff (input .expectedClusterRoleBindings , toBeTest ); ! equal {
72
- t .Errorf ("%s:\n %s" , input .description , diff )
73
- t .Fatalf ("unexpected difference in RBAC cluster role: \n got \n %v\n want\n %v" , got , input .expectedClusterRoleBindings )
74
- }
67
+
68
+ td .Cmp (t , input .expectedClusterRoleBindings , toBeTest )
75
69
}
76
70
}
0 commit comments