diff --git a/internal/s3/mock.go b/internal/s3/mock.go index 20beb27..ee62b54 100644 --- a/internal/s3/mock.go +++ b/internal/s3/mock.go @@ -47,14 +47,30 @@ func (m *mockS3) ListBuckets(ctx context.Context) ([]string, error) { func (m *mockS3) ListObjects(ctx context.Context, id types.ID) ([]Object, error) { var results []Object + dirs := make(map[string]bool) + + depth := len(strings.Split(id.Key, "/")) + for k, v := range m.objects { if k.Bucket == id.Bucket { if k.Parent().Key == id.Key { results = append(results, *mockObjToObject(v, k)) + } else if strings.HasPrefix(k.Key, id.Key) { + s := strings.Join(strings.Split(k.Key, "/")[:depth], "/") + "/" + dirs[s] = true } } } + for k := range dirs { + results = append(results, Object{ + ID: types.ID{ + Bucket: id.Bucket, + Key: k, + }, + }) + } + return results, nil }