@@ -56,3 +56,38 @@ func TestResourceName(t *testing.T) {
56
56
test .Expect (err ).To (gomega .BeNil (), "Expected no error, but got '%v'" , err )
57
57
test .Expect (resourceName ).To (gomega .Equal ("test-resource" ), "Expected resource name 'test-resource', but got '%s'" , resourceName )
58
58
}
59
+
60
+ func TestGetServiceAccount (t * testing.T ) {
61
+ test := NewTest (t )
62
+
63
+ createdSa := & corev1.ServiceAccount {
64
+ ObjectMeta : metav1.ObjectMeta {
65
+ Name : "my-sa" ,
66
+ Namespace : "my-namespace" ,
67
+ },
68
+ }
69
+
70
+ test .client .Core ().CoreV1 ().ServiceAccounts ("my-namespace" ).Create (test .ctx , createdSa , metav1.CreateOptions {})
71
+ sa := GetServiceAccount (test , "my-namespace" , "my-sa" )
72
+
73
+ test .Expect (sa .Name ).To (gomega .Equal ("my-sa" ))
74
+ test .Expect (sa .Namespace ).To (gomega .Equal ("my-namespace" ))
75
+ }
76
+
77
+ func TestGetServiceAccounts (t * testing.T ) {
78
+ test := NewTest (t )
79
+
80
+ createdSa := & corev1.ServiceAccount {
81
+ ObjectMeta : metav1.ObjectMeta {
82
+ Name : "my-sa-1" ,
83
+ Namespace : "my-namespace" ,
84
+ },
85
+ }
86
+
87
+ test .client .Core ().CoreV1 ().ServiceAccounts ("my-namespace" ).Create (test .ctx , createdSa , metav1.CreateOptions {})
88
+ sas := GetServiceAccounts (test , "my-namespace" )
89
+
90
+ test .Expect (len (sas )).To (gomega .Equal (1 ))
91
+ test .Expect (sas [0 ].Name ).To (gomega .Equal ("my-sa-1" ))
92
+ test .Expect (sas [0 ].Namespace ).To (gomega .Equal ("my-namespace" ))
93
+ }
0 commit comments