diff --git a/oss/gcsblob/gcs.go b/oss/gcsblob/gcs.go index 43a8eb4..40fdfc5 100644 --- a/oss/gcsblob/gcs.go +++ b/oss/gcsblob/gcs.go @@ -116,7 +116,7 @@ func (g *GoogleCloudStorage) List(prefix string) ([]oss.OSSPath, error) { key = strings.TrimPrefix(key, "/") res = append(res, oss.OSSPath{ - Path: attrs.Name, + Path: key, IsDir: false, }) diff --git a/tests/oss/oss_test.go b/tests/oss/oss_test.go index f606a53..8957491 100644 --- a/tests/oss/oss_test.go +++ b/tests/oss/oss_test.go @@ -174,6 +174,9 @@ func TestAll(t *testing.T) { ossPaths, err = storage.List(prefix) assert.Equal(t, 1, len(ossPaths), info) assert.Nil(t, err, info) + // Verify that List returns relative paths (without prefix) + expectedRelativePath := key[len(prefix)+1:] // +1 for the "/" separator + assert.Equal(t, expectedRelativePath, ossPaths[0].Path, info+" - List should return relative path") err = storage.Delete(key) assert.Nil(t, err, info)