Skip to content

Commit 6609166

Browse files
refactor(storage): Update Dual-Region Bucket Creation Metadata (GoogleCloudPlatform#1669)
* refactor(storage): Update Dual-Region Bucket Creation Metadata * fix: lint
1 parent 8ba0e0b commit 6609166

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

storage/src/create_bucket_dual_region.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,13 @@ function create_bucket_dual_region($bucketName, $location, $region1, $region2)
4848
'dataLocations' => [$region1, $region2],
4949
],
5050
]);
51-
printf("Bucket '%s' created in '%s' and '%s'", $bucket->name(), $region1, $region2);
51+
52+
$info = $bucket->info();
53+
54+
printf("Created '%s':", $bucket->name());
55+
printf("- location: '%s'", $info['location']);
56+
printf("- locationType: '%s'", $info['locationType']);
57+
printf("- customPlacementConfig: '%s'" . PHP_EOL, print_r($info['customPlacementConfig'], true));
5258
}
5359
# [END storage_create_bucket_dual_region]
5460

storage/test/storageTest.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ public function testCreateBucketDualRegion()
677677
$location = 'US';
678678
$region1 = 'US-EAST1';
679679
$region2 = 'US-WEST1';
680+
$locationType = 'dual-region';
680681

681682
$bucketName = uniqid('samples-create-bucket-dual-region-');
682683
$output = self::runFunctionSnippet('create_bucket_dual_region', [
@@ -692,16 +693,14 @@ public function testCreateBucketDualRegion()
692693
$bucket->delete();
693694

694695
$this->assertTrue($exists);
695-
$this->assertEquals(
696-
sprintf(
697-
"Bucket '%s' created in '%s' and '%s'",
698-
$bucketName,
699-
$region1,
700-
$region2
701-
),
702-
$output
703-
);
696+
$this->assertStringContainsString($bucketName, $output);
697+
$this->assertStringContainsString($location, $output);
698+
$this->assertStringContainsString($locationType, $output);
699+
$this->assertStringContainsString($region1, $output);
700+
$this->assertStringContainsString($region2, $output);
701+
704702
$this->assertEquals($location, $info['location']);
703+
$this->assertEquals($locationType, $info['locationType']);
705704
$this->assertArrayHasKey('customPlacementConfig', $info);
706705
$this->assertArrayHasKey('dataLocations', $info['customPlacementConfig']);
707706
$this->assertContains($region1, $info['customPlacementConfig']['dataLocations']);

0 commit comments

Comments
 (0)