Skip to content

Commit

Permalink
Set readPreference in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed May 21, 2024
1 parent 8fef05c commit 22b1361
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/GridFS/GridFSAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use League\Flysystem\UnableToWriteFile;
use MongoDB\Client;
use MongoDB\Database;
use MongoDB\Driver\ReadPreference;
use function getenv;

/**
Expand Down Expand Up @@ -146,7 +147,6 @@ public function reading_last_revision(): void
$this->runScenario(
function () {
$this->givenWeHaveAnExistingFile('file.txt', 'version 1');
usleep(10);
$this->givenWeHaveAnExistingFile('file.txt', 'version 2');

$this->assertSame('version 2', $this->adapter()->read('file.txt'));
Expand All @@ -165,7 +165,6 @@ public function listing_contents_last_revision(bool $deep): void
$this->runScenario(
function () use ($deep) {
$this->givenWeHaveAnExistingFile('file.txt', 'version 1');
usleep(10);
$this->givenWeHaveAnExistingFile('file.txt', 'version 2');

$files = $this->adapter()->listContents('', $deep);
Expand Down Expand Up @@ -227,9 +226,7 @@ public function move_all_revisions(): void
$this->runScenario(
function () {
$this->givenWeHaveAnExistingFile('file.txt', 'version 1');
usleep(10);
$this->givenWeHaveAnExistingFile('file.txt', 'version 2');
usleep(10);
$this->givenWeHaveAnExistingFile('file.txt', 'version 3');

$this->adapter()->move('file.txt', 'destination.txt', new Config());
Expand Down Expand Up @@ -260,7 +257,9 @@ private static function getDatabase(): Database
{
$uri = getenv('MONGODB_URI') ?: 'mongodb://127.0.0.1:27017/';

$client = new Client($uri);
$client = new Client($uri, [], [
'readPreference' => new ReadPreference(ReadPreference::PRIMARY),
]);

return $client->selectDatabase(getenv('MONGODB_DATABASE') ?: 'flysystem_tests');
}
Expand Down

0 comments on commit 22b1361

Please sign in to comment.