fix typo and add unit test

This commit is contained in:
jixinchi 2023-11-14 17:29:16 +08:00 committed by Andrew Gaul
parent ef09dbb6ad
commit 311a4102da
2 changed files with 16 additions and 1 deletions

View File

@ -367,7 +367,6 @@ public final class LocalBlobStore implements BlobStore {
if (!contents.contains(md)) { if (!contents.contains(md)) {
contents.add(md); contents.add(md);
} }
contents.add(md);
} }
return contents; return contents;
} }

View File

@ -193,6 +193,22 @@ public class ListContainerTest {
assertThat(Iterables.get(results, 0).getType()).isNotEqualTo(StorageType.RELATIVE_PATH); assertThat(Iterables.get(results, 0).getType()).isNotEqualTo(StorageType.RELATIVE_PATH);
} }
public void testListBlobEndsWithDelimiterAndDelimiterFilter() {
String containerName = "testListBlobEndsWithDelimiterAndDelimiterFilter";
blobStore.createContainerInLocation(null, containerName);
blobStore.putBlob(containerName, blobStore.blobBuilder("foo/").type(StorageType.FOLDER)
.payload(ByteSource.empty()).build());
blobStore.putBlob(containerName, blobStore.blobBuilder("bar/text").type(StorageType.BLOB)
.payload(ByteSource.empty()).build());
PageSet<? extends StorageMetadata> results = blobStore.list(containerName,
ListContainerOptions.Builder.delimiter("/"));
assertThat(results.size()).isEqualTo(2);
assertThat(Iterables.get(results, 0).getName()).isEqualTo("bar/");
assertThat(Iterables.get(results, 0).getType()).isEqualTo(StorageType.RELATIVE_PATH);
assertThat(Iterables.get(results, 1).getName()).isEqualTo("foo/");
assertThat(Iterables.get(results, 1).getType()).isEqualTo(StorageType.FOLDER);
}
public void testDirectoryListing() { public void testDirectoryListing() {
String containerName = "testDirectoryListing"; String containerName = "testDirectoryListing";
blobStore.createContainerInLocation(null, containerName); blobStore.createContainerInLocation(null, containerName);