Skip to content

Commit

Permalink
Add integration test for replacing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
mziccard committed Oct 22, 2015
1 parent 3b91741 commit 99178a3
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import static org.junit.Assert.fail;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.gcloud.RestorableState;
import com.google.gcloud.storage.testing.RemoteGcsHelper;

Expand Down Expand Up @@ -174,6 +175,23 @@ public void testUpdateBlob() {
assertTrue(storage.delete(bucket, blobName));
}

@Test
public void testUpdateBlobReplaceMetadata() {
String blobName = "test-update-blob-replace-metadata";
BlobInfo blob = BlobInfo.builder(bucket, blobName)
.contentType(CONTENT_TYPE)
.metadata(ImmutableMap.of("k1", "a"))
.build();
assertNotNull(storage.create(blob));
BlobInfo updatedBlob = storage.update(blob.toBuilder().metadata(null).build());
assertNotNull(updatedBlob);
assertNull(updatedBlob.metadata());
updatedBlob = storage.update(blob.toBuilder().metadata(ImmutableMap.of("k2", "b")).build());
assertEquals(blob.blobId(), updatedBlob.blobId());
assertEquals(ImmutableMap.of("k2", "b"), updatedBlob.metadata());
assertTrue(storage.delete(bucket, blobName));
}

@Test
public void testUpdateBlobFail() {
String blobName = "test-update-blob-fail";
Expand Down

0 comments on commit 99178a3

Please sign in to comment.