Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Custom Part Metadata Decorator to ParallelCompositeUploadConfig #2434

Merged
merged 24 commits into from
Mar 15, 2024
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
unit test for offset calculations
  • Loading branch information
sydney-munro committed Mar 15, 2024
commit 6678349c52b9d16377da8a5b0035757ff1c83d9d
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@
import static com.google.common.truth.Truth.assertWithMessage;

import com.google.cloud.storage.MetadataField.PartRange;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.PartMetadataFieldDecorator;
import com.google.cloud.storage.ParallelCompositeUploadBlobWriteSessionConfig.PartNamingStrategy;
import com.google.common.truth.StringSubject;
import java.time.Duration;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneId;
import org.junit.Test;

public final class ParallelCompositeUploadBlobWriteSessionConfigTest {
Expand Down Expand Up @@ -87,6 +92,17 @@ public void partNameStrategy_objectNamePrefix() throws Exception {
() -> assertThat(fmt).startsWith("a/b/obj"));
BenWhitehead marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void partMetadataFieldDecorator_customTime() {
BlobInfo.Builder testBlob = BlobInfo.newBuilder("testBlob", "testBucket");
Duration duration = Duration.ofSeconds(30);
TestClock clock = TestClock.tickBy(Instant.EPOCH, Duration.ofSeconds(1));
OffsetDateTime expected = OffsetDateTime.from(Instant.EPOCH.plus(duration).atZone(ZoneId.of("Z")));
PartMetadataFieldDecorator.setCustomTimeInFuture(duration).newInstance(clock).apply(testBlob);

assertThat(expected).isEqualTo(testBlob.build().getCustomTimeOffsetDateTime());
}

private static StringSubject assertField(String fmt, int idx) {
String[] split = fmt.split(";");
String s = split[idx];
Expand Down