44 "testing"
55
66 "github.com/golang/mock/gomock"
7- "google.golang.org/grpc/codes"
8- "google.golang.org/grpc/status"
97
108 "github.com/kubernetes-sigs/aws-efs-csi-driver/pkg/driver/mocks"
119)
@@ -14,26 +12,29 @@ func TestProvisioner_GetCloud_NoRoleArnGivesOriginalObjectBack(t *testing.T) {
1412 mockCtl := gomock .NewController (t )
1513 mockCloud := mocks .NewMockCloud (mockCtl )
1614
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+ }
1819 if actualCloud != mockCloud {
1920 t .Fatalf ("Expected cloud object to be %v but was %v" , mockCloud , actualCloud )
2021 }
2122
2223 mockCtl .Finish ()
2324}
2425
25- func TestProvisioner_GetCloud_IncorrectRoleArnGivesError (t * testing.T ) {
26+ func TestProvisioner_GetCloud_WithRoleArnGivesNewObject (t * testing.T ) {
2627 mockCtl := gomock .NewController (t )
2728 mockCloud := mocks .NewMockCloud (mockCtl )
2829
29- _ , _ , _ , err := getCloud (map [string ]string {
30- RoleArn : "foo " ,
30+ actualCloud , _ , _ , err := getCloud (map [string ]string {
31+ RoleArn : "arn:aws:iam::1234567890:role/EFSCrossAccountRole " ,
3132 }, 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 )
3435 }
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 )
3738 }
3839
3940 mockCtl .Finish ()
0 commit comments