go-storage icon indicating copy to clipboard operation
go-storage copied to clipboard

test: `TestListEmptyDir` expected behavior does not apply to some file hosting service

Open JinnyYi opened this issue 3 years ago • 2 comments

https://github.com/beyondstorage/go-storage/blob/813c8a192cfc9f43eac39d66a910cf8d6512b7ec/tests/storager_list.go#L86-L96

path is currently a non-existent path for the service. When listing a non-existent dir:

  • For object storage services, ListObjects will get an empty Contents in ListBucketResult, in line with the expected behavior.
  • For fs, although list does not return an error, we will get no such file or directory error when calling Next().
  • For dropbox: ListFolder will return path/not_found/... error.

JinnyYi avatar Nov 18 '21 03:11 JinnyYi

Maybe TestListEmptyDir should list an existing empty dir?

How about CreateDir(path) before List? But the service should support CreateDir feature. I'm not sure it's appropriate to check s.p.store.Features().CreateDir in TestListEmptyDir. If we judge in TestList, all of test cases for List may not be executed.

JinnyYi avatar Nov 18 '21 06:11 JinnyYi

After adding CreateDir(path) before List, file hosting services basically passes the test now, but the object storage services no longer passes the test:

  • TestListEmptyDir will get the object workdir/path/ with size 0 in s3 and cos, maybe more services.
  • TestListEmptyDir test case will be passed when testing service s3 with minio.

JinnyYi avatar Nov 23 '21 06:11 JinnyYi