4
4
"testing"
5
5
6
6
"github.com/golang/mock/gomock"
7
- "google.golang.org/grpc/codes"
8
- "google.golang.org/grpc/status"
9
7
10
8
"github.com/kubernetes-sigs/aws-efs-csi-driver/pkg/driver/mocks"
11
9
)
@@ -14,26 +12,29 @@ func TestProvisioner_GetCloud_NoRoleArnGivesOriginalObjectBack(t *testing.T) {
14
12
mockCtl := gomock .NewController (t )
15
13
mockCloud := mocks .NewMockCloud (mockCtl )
16
14
17
- actualCloud , _ , _ , _ := getCloud (map [string ]string {}, mockCloud )
15
+ actualCloud , _ , _ , err := getCloud (map [string ]string {}, mockCloud )
16
+ if err != nil {
17
+ t .Fatalf ("Unexpected error: %v" , err )
18
+ }
18
19
if actualCloud != mockCloud {
19
20
t .Fatalf ("Expected cloud object to be %v but was %v" , mockCloud , actualCloud )
20
21
}
21
22
22
23
mockCtl .Finish ()
23
24
}
24
25
25
- func TestProvisioner_GetCloud_IncorrectRoleArnGivesError (t * testing.T ) {
26
+ func TestProvisioner_GetCloud_WithRoleArnGivesNewObject (t * testing.T ) {
26
27
mockCtl := gomock .NewController (t )
27
28
mockCloud := mocks .NewMockCloud (mockCtl )
28
29
29
- _ , _ , _ , err := getCloud (map [string ]string {
30
- RoleArn : "foo " ,
30
+ actualCloud , _ , _ , err := getCloud (map [string ]string {
31
+ RoleArn : "arn:aws:iam::1234567890:role/EFSCrossAccountRole " ,
31
32
}, mockCloud )
32
- if err = = nil {
33
- t .Fatalf ("Expected error but none was returned" )
33
+ if err ! = nil {
34
+ t .Fatalf ("Unexpected error: %v" , err )
34
35
}
35
- if status . Code ( err ) != codes . Unauthenticated {
36
- t .Fatalf ("Expected 'Unauthenticated' error but found %v" , err )
36
+ if actualCloud == mockCloud {
37
+ t .Fatalf ("Unexpected cloud object: %v" , actualCloud )
37
38
}
38
39
39
40
mockCtl .Finish ()
0 commit comments