beyondstorage / go-storage

A vendor-neutral storage library for Golang: Write once, run on every storage service.

Home Page:https://beyondstorage.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

JinnyYi opened this issue · comments

func (s *storageListSuite) TestListEmptyDir() {
path := uuid.New().String()
it, err := s.p.store.List(path, ps.WithListMode(types.ListModeDir))
s.NoError(err)
s.NotNil(it)
o, err := it.Next()
s.ErrorIs(err, types.IterateDone)
s.Nil(o)
}

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.

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.

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.