Skip to content

Commit 57510f6

Browse files
committed
fix system test
1 parent ae37686 commit 57510f6

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

Core/src/LongRunning/LongRunningGapicConnection.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919

2020
use Google\ApiCore\OperationResponse;
2121
use Google\ApiCore\Serializer;
22+
use Google\Cloud\Core\RequestProcessorTrait;
2223
use Google\LongRunning\Operation;
2324
use Google\LongRunning\ListOperationsRequest;
2425
use Google\LongRunning\GetOperationRequest;
2526
use Google\LongRunning\CancelOperationRequest;
2627
use Google\LongRunning\DeleteOperationRequest;
27-
use Google\Cloud\Core\RequestProcessorTrait;
28+
use Google\Protobuf\Any;
2829

2930
/**
3031
* Defines the calls required to manage Long Running Operations using a GAPIC
@@ -97,7 +98,12 @@ private function operationResponseToArray(OperationResponse $operationResponse)
9798
$metaType = $response['metadata']['typeUrl'];
9899

99100
// unpack result Any type
100-
$response['response'] = $this->handleResponse($operationResponse->getResult());
101+
$result = $operationResponse->getResult();
102+
if ($result instanceof Any) {
103+
// For some reason we aren't doing this in GAX OperationResponse (but we should)
104+
$result = $result->unpack();
105+
}
106+
$response['response'] = $this->handleResponse($result);
101107

102108
// unpack error Any type
103109
$response['error'] = $this->handleResponse($operationResponse->getError());

Spanner/tests/System/AdminTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
namespace Google\Cloud\Spanner\Tests\System;
1919

20-
use Google\ApiCore\OperationResponse;
2120
use Google\Cloud\Core\Exception\FailedPreconditionException;
22-
use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient;
21+
use Google\Cloud\Core\LongRunning\LongRunningOperation;
22+
use Google\Cloud\Spanner\Admin\Database\V1\Client\DatabaseAdminClient;
2323
use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect;
2424
use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient;
2525
use Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig\Type;
@@ -62,7 +62,7 @@ public function testInstance()
6262
'processingUnits' => $processingUnits,
6363
]);
6464

65-
$this->assertInstanceOf(OperationResponse::class, $op);
65+
$this->assertInstanceOf(LongRunningOperation::class, $op);
6666
$op->pollUntilComplete();
6767

6868
$instance = $client->instance(self::INSTANCE_NAME);
@@ -97,9 +97,9 @@ public function testDatabase()
9797
$dbName = uniqid(self::TESTING_PREFIX);
9898
$op = $instance->createDatabase($dbName);
9999

100-
$this->assertInstanceOf(OperationResponse::class, $op);
100+
$this->assertInstanceOf(LongRunningOperation::class, $op);
101101
$op->pollUntilComplete();
102-
$db = $op->getResult();
102+
$db = $op->result();
103103
$this->assertInstanceOf(Database::class, $db);
104104

105105
self::$deletionQueue->add(function () use ($db) {
@@ -141,9 +141,9 @@ public function testDatabaseDropProtection()
141141
$dbName = uniqid(self::TESTING_PREFIX);
142142
$op = $instance->createDatabase($dbName);
143143

144-
$this->assertInstanceOf(OperationResponse::class, $op);
144+
$this->assertInstanceOf(LongRunningOperation::class, $op);
145145
$op->pollUntilComplete();
146-
$db = $op->getResult();
146+
$db = $op->result();
147147
$this->assertInstanceOf(Database::class, $db);
148148

149149
$info = $db->reload();
@@ -246,7 +246,7 @@ public function testCreateCustomerManagedInstanceConfiguration()
246246
$replicas[array_rand($replicas)]['defaultLeaderLocation'] = true;
247247
$op = $customConfiguration->create($baseConfig, $replicas);
248248

249-
$this->assertInstanceOf(OperationResponse::class, $op);
249+
$this->assertInstanceOf(LongRunningOperation::class, $op);
250250
$op->pollUntilComplete();
251251

252252
$this->assertTrue($customConfiguration->exists());
@@ -332,7 +332,7 @@ public function testPgDatabase()
332332
'databaseDialect' => DatabaseDialect::POSTGRESQL
333333
]);
334334

335-
$this->assertInstanceOf(OperationResponse::class, $op);
335+
$this->assertInstanceOf(LongRunningOperation::class, $op);
336336
$db = $op->pollUntilComplete();
337337
$this->assertInstanceOf(Database::class, $db);
338338

0 commit comments

Comments
 (0)