Skip to content

Commit

Permalink
Fix unit test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
yash30201 committed Apr 4, 2024
1 parent 0596f27 commit fa9e30a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
4 changes: 0 additions & 4 deletions Core/tests/Unit/ServiceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use Google\Cloud\Core\ServiceBuilder;
use Google\Cloud\Core\Testing\CheckForClassTrait;
use Google\Cloud\Core\Testing\GrpcTestTrait;
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Firestore\FirestoreClient;
use Google\Cloud\Language\LanguageClient;
use Google\Cloud\Logging\LoggingClient;
Expand Down Expand Up @@ -161,9 +160,6 @@ public function serviceProvider()
[
'bigQuery',
BigQueryClient::class
], [
'datastore',
DatastoreClient::class
], [
'firestore',
FirestoreClient::class,
Expand Down
8 changes: 5 additions & 3 deletions Datastore/tests/Unit/DatastoreClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
use Google\Cloud\Core\RequestHandler;
use Google\Cloud\Core\Testing\DatastoreOperationRefreshTrait;
use Google\Cloud\Core\Testing\GrpcTestTrait;
use Google\Cloud\Core\Testing\Snippet\Fixtures;
use Google\Cloud\Core\Testing\TestHelpers;
use Google\Cloud\Core\Timestamp;
use Google\Cloud\Datastore\Blob;
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Datastore\Entity;
use Google\Cloud\Datastore\GeoPoint;
use Google\Cloud\Datastore\Key;
use Google\Cloud\Datastore\Query\Aggregation;
use Google\Cloud\Datastore\Query\AggregationQuery;
use Google\Cloud\Datastore\Query\AggregationQueryResult;
use Google\Cloud\Datastore\Query\GqlQuery;
Expand All @@ -40,7 +40,6 @@
use Google\Cloud\Datastore\Transaction;
use Google\Cloud\Datastore\V1\CommitRequest\Mode;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;

/**
Expand All @@ -63,7 +62,10 @@ class DatastoreClientTest extends TestCase
public function setUp(): void
{
$this->client = TestHelpers::stub(DatastoreClient::class, [
['projectId' => self::PROJECT]
[
'projectId' => self::PROJECT,
'credentials' => Fixtures::KEYFILE_STUB_FIXTURE()
]
], [
'operation'
]);
Expand Down
32 changes: 0 additions & 32 deletions Datastore/tests/Unit/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,38 +132,6 @@ public function testLookup(callable $transaction)
$this->assertEquals($this->key->keyObject(), $res->key()->keyObject());
}

public function testLookupWithReadTime()

This comment has been minimized.

Copy link
@yash30201

yash30201 Apr 4, 2024

Author Contributor

Removing this test as it's not a valid scenario.

Transactions in Datastore are used for ensuring consistency and isolation,
but they do not provide the ability to specify a specific read time.
Transactions guarantee that all reads and writes within the transaction are
consistent with each other and appear to have occurred at a single point
in time, but the exact timestamp of that point is not configurable.

{
$time = new Timestamp(new \DateTime());

$this->mockSendRequest(
'lookup',
[
'readOptions' => [
'readTime' => $time,
'transaction' => self::TRANSACTION,
],
'keys' => [$this->key->keyObject()],
],
[
'found' => [
[
'entity' => $this->entityArray($this->key)
]
]
],
0
);

$transaction = $this->readOnly;
$this->refreshOperation($transaction,$this->requestHandler->reveal(), [
'projectId' => self::PROJECT
]);

$res = $transaction->lookup($this->key, ['readTime' => $time]);
$this->assertInstanceOf(Entity::class, $res);
}

/**
* @dataProvider transactionProvider
*/
Expand Down

0 comments on commit fa9e30a

Please sign in to comment.