Skip to content

Commit

Permalink
Merge pull request #39 from utopia-php/disable-document-cache
Browse files Browse the repository at this point in the history
Disable Document cache
  • Loading branch information
abnegate authored Sep 5, 2024
2 parents 33d2fed + 530ed66 commit fe7c8a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
8 changes: 8 additions & 0 deletions src/Migration/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ public function add(Resource $resource): void
$resource->setData(''); // Prevent Memory Leak
}

if($resource->getName() == Resource::TYPE_DOCUMENT) {
return;
}

$this->cache[$resource->getName()][$resource->getInternalId()] = $resource;
}

Expand Down Expand Up @@ -75,6 +79,10 @@ public function update(Resource $resource): void
$this->add($resource);
}

if($resource->getName() == Resource::TYPE_DOCUMENT) {
return;
}

$this->cache[$resource->getName()][$resource->getInternalId()] = $resource;
}

Expand Down
36 changes: 18 additions & 18 deletions tests/Migration/E2E/Sources/SupabaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,24 @@ public function testValidateDatabaseTransfer($state)

// Find Known Documents
$documents = $state['source']->cache->get(Resource::TYPE_DOCUMENT);
$this->assertGreaterThan(0, count($documents));

$foundDocument = null;

foreach ($documents as $document) {
/** @var Document $document */
if ($document->getCollection()->getDatabase()->getDatabaseName() === 'public' && $document->getCollection()->getCollectionName() === 'test') {
$foundDocument = $document;
}

break;
}

if (! $foundDocument) {
$this->fail('Document "1" not found');
}

$this->assertEquals('success', $foundDocument->getStatus());
// $this->assertGreaterThan(0, count($documents));
//
// $foundDocument = null;
//
// foreach ($documents as $document) {
// /** @var Document $document */
// if ($document->getCollection()->getDatabase()->getDatabaseName() === 'public' && $document->getCollection()->getCollectionName() === 'test') {
// $foundDocument = $document;
// }
//
// break;
// }
//
// if (! $foundDocument) {
// $this->fail('Document "1" not found');
// }
//
// $this->assertEquals('success', $foundDocument->getStatus());

return $state;
}
Expand Down

0 comments on commit fe7c8a4

Please sign in to comment.