@@ -278,43 +278,49 @@ func TestS3Getter_Url(t *testing.T) {
278
278
279
279
func Test_S3Getter_ParseUrl_Malformed (t * testing.T ) {
280
280
tests := []struct {
281
- name string
282
- url string
281
+ name string
282
+ input string
283
+ expected string
283
284
}{
284
285
{
285
- name : "path style" ,
286
- url : "https://s3.amazonaws.com/bucket" ,
286
+ name : "path style" ,
287
+ input : "https://s3.amazonaws.com/bucket" ,
288
+ expected : "URL is not a valid S3 URL" ,
287
289
},
288
290
{
289
- name : "vhost-style, dash region indication" ,
290
- url : "https://bucket.s3-us-east-1.amazonaws.com" ,
291
+ name : "vhost-style, dash region indication" ,
292
+ input : "https://bucket.s3-us-east-1.amazonaws.com" ,
293
+ expected : "URL is not a valid S3 URL" ,
291
294
},
292
295
{
293
- name : "vhost-style, dot region indication" ,
294
- url : "https://bucket.s3.us-east-1.amazonaws.com" ,
296
+ name : "vhost-style, dot region indication" ,
297
+ input : "https://bucket.s3.us-east-1.amazonaws.com" ,
298
+ expected : "URL is not a valid S3 URL" ,
295
299
},
296
300
{
297
- name : "invalid host parts" ,
298
- url : "https://invalid.host.parts.lenght.s3.us-east-1.amazonaws.com" ,
301
+ name : "invalid host parts" ,
302
+ input : "https://invalid.host.parts.lenght.s3.us-east-1.amazonaws.com" ,
303
+ expected : "URL is not a valid S3 URL" ,
299
304
},
300
305
{
301
- name : "invalid host suffix" ,
302
- url : "https://bucket.s3.amazonaws.com.invalid" ,
306
+ name : "invalid host suffix" ,
307
+ input : "https://bucket.s3.amazonaws.com.invalid" ,
308
+ expected : "URL is not a valid S3 compliant URL" ,
303
309
},
304
310
}
305
311
for _ , tt := range tests {
306
312
t .Run (tt .name , func (t * testing.T ) {
307
313
g := new (S3Getter )
308
- u , err := url .Parse (tt .url )
314
+ u , err := url .Parse (tt .input )
309
315
if err != nil {
310
316
t .Fatalf ("unexpected error: %s" , err )
311
317
}
312
318
_ , _ , _ , _ , _ , err = g .parseUrl (u )
313
319
if err == nil {
314
320
t .Fatalf ("expected error, got none" )
315
321
}
316
- if err .Error () != "URL is not a valid S3 URL" {
317
- t .Fatalf ("expected error 'URL is not a valid S3 URL ', got %s" , err .Error ())
322
+ if err .Error () != tt . expected {
323
+ t .Fatalf ("expected error '%s ', got %s for %s " , tt . expected , err .Error (), tt . name )
318
324
}
319
325
})
320
326
}
0 commit comments