@@ -158,6 +158,38 @@ func TestCreateAccessPoint(t *testing.T) {
158
158
mockCtl .Finish ()
159
159
},
160
160
},
161
+ {
162
+ name : "Error: Access Point already exists" ,
163
+ testFunc : func (t * testing.T ) {
164
+ mockCtl := gomock .NewController (t )
165
+ mockEfs := mocks .NewMockEfs (mockCtl )
166
+ c := & cloud {efs : mockEfs }
167
+
168
+ req := & AccessPointOptions {
169
+ FileSystemId : fsId ,
170
+ Uid : uid ,
171
+ Gid : gid ,
172
+ DirectoryPerms : directoryPerms ,
173
+ DirectoryPath : directoryPath ,
174
+ }
175
+
176
+ ctx := context .Background ()
177
+ mockEfs .EXPECT ().CreateAccessPoint (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil ,
178
+ & smithy.GenericAPIError {
179
+ Code : AccessPointAlreadyExists ,
180
+ Message : "Access point already exists" ,
181
+ })
182
+
183
+ _ , err := c .CreateAccessPoint (ctx , clientToken , req )
184
+ if err == nil {
185
+ t .Fatalf ("CreateAccessPoint did not return error" )
186
+ }
187
+ if err != ErrAlreadyExists {
188
+ t .Fatalf ("Failed. Expected: %v, Actual:%v" , ErrAlreadyExists , err )
189
+ }
190
+ mockCtl .Finish ()
191
+ },
192
+ },
161
193
}
162
194
163
195
for _ , tc := range testCases {
@@ -1085,6 +1117,16 @@ func Test_findAccessPointByPath(t *testing.T) {
1085
1117
FileSystemId : fsId ,
1086
1118
}
1087
1119
1120
+ expectedSingleAPWithPosixUser := & AccessPoint {
1121
+ AccessPointId : "testApId" ,
1122
+ AccessPointRootDir : dirPath ,
1123
+ PosixUser : & PosixUser {
1124
+ Uid : 1000 ,
1125
+ Gid : 1000 ,
1126
+ },
1127
+ FileSystemId : fsId ,
1128
+ }
1129
+
1088
1130
type args struct {
1089
1131
clientToken string
1090
1132
accessPointOpts * AccessPointOptions
@@ -1105,10 +1147,16 @@ func Test_findAccessPointByPath(t *testing.T) {
1105
1147
mockEfs .EXPECT ().DescribeAccessPoints (gomock .Any (), gomock .Any (), gomock .Any ()).Return (& efs.DescribeAccessPointsOutput {
1106
1148
AccessPoints : []types.AccessPointDescription {
1107
1149
{FileSystemId : aws .String (fsId ), ClientToken : diffClientToken , AccessPointId : aws .String ("differentApId" ), RootDirectory : & types.RootDirectory {Path : aws .String (expectedSingleAP .AccessPointRootDir )}},
1108
- {FileSystemId : aws .String (fsId ), ClientToken : & clientToken , AccessPointId : aws .String (expectedSingleAP .AccessPointId ), RootDirectory : & types.RootDirectory {Path : aws .String (expectedSingleAP .AccessPointRootDir )}},
1150
+ {
1151
+ FileSystemId : aws .String (fsId ),
1152
+ ClientToken : & clientToken ,
1153
+ AccessPointId : aws .String (expectedSingleAPWithPosixUser .AccessPointId ),
1154
+ RootDirectory : & types.RootDirectory {Path : aws .String (expectedSingleAPWithPosixUser .AccessPointRootDir )},
1155
+ PosixUser : & types.PosixUser {Gid : aws .Int64 (1000 ), Uid : aws .Int64 (1000 )},
1156
+ },
1109
1157
},
1110
1158
}, nil )
1111
- }, wantAccessPoint : expectedSingleAP , wantErr : false },
1159
+ }, wantAccessPoint : expectedSingleAPWithPosixUser , wantErr : false },
1112
1160
{name : "Fail_DescribeAccessPoints" , args : args {clientToken , & AccessPointOptions {FileSystemId : fsId , DirectoryPath : dirPath }}, prepare : func (mockEfs * mocks.MockEfs ) {
1113
1161
mockEfs .EXPECT ().DescribeAccessPoints (gomock .Any (), gomock .Any (), gomock .Any ()).Return (nil , errors .New ("access_denied" ))
1114
1162
}, wantAccessPoint : nil , wantErr : true },
0 commit comments