Skip to content

Commit 0567e39

Browse files
committed
chore: slightly improve code samples
1 parent b5de3cd commit 0567e39

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

spanner/src/cancel_backup.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ function cancel_backup_operation($instanceId, $databaseId)
5555
printf('Cancel backup operation complete.' . PHP_EOL);
5656

5757
// Operation may succeed before cancel() has been called. So we need to clean up created backup.
58-
$backup->delete();
58+
if ($backup->exists()) {
59+
$backup->delete();
60+
}
5961
}
6062
// [END spanner_cancel_backup_create]

spanner/src/list_backups.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function list_backups($instanceId)
7979
}
8080

8181
// List backups that were created after a timestamp that are also ready.
82-
$createTime = $spanner->timestamp(new \DateTime('-1 hour'));
82+
$createTime = $spanner->timestamp(new \DateTime('-1 day'));
8383
print("All backups created after $createTime:" . PHP_EOL);
8484
$filter = "create_time >= \"$createTime\" AND state:READY";
8585
foreach ($instance->backups(['filter' => $filter]) as $backup) {

spanner/src/list_database_operations.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
use Google\Cloud\Spanner\SpannerClient;
2828

2929
/**
30-
* List all database operations in an instance.
30+
* List all optimize restored database operations in an instance.
3131
* Example:
3232
* ```
3333
* list_database_operations($instanceId);

spanner/test/spannerTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,19 +651,18 @@ public function testListBackupOperations()
651651
}
652652

653653
/**
654-
* @depends testListBackupOperations
654+
* @depends testCreateBackup
655655
*/
656656
public function testListBackups()
657657
{
658658
$output = $this->traitRunCommand('list-backups', [
659659
'instance_id' => self::$instanceId,
660660
]);
661661
$this->assertContains(self::$backupId, $output);
662-
$this->assertContains(self::$backupId . '-pro', $output);
663662
}
664663

665664
/**
666-
* @depends testListBackups
665+
* @depends testCreateBackup
667666
*/
668667
public function testUpdateBackup()
669668
{

0 commit comments

Comments
 (0)