Skip to content

Commit

Permalink
Rename tests to unit
Browse files Browse the repository at this point in the history
  • Loading branch information
PineappleIOnic committed Jun 3, 2024
1 parent eba675f commit 75ec3cc
Show file tree
Hide file tree
Showing 12 changed files with 306 additions and 174 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ jobs:
key: ${{ env.CACHE_KEY }}
path: /tmp/${{ env.IMAGE }}.tar

source_e2e_tests:
name: Run Source E2E Tests
source_unit_tests:
name: Run Source Unit Tests
runs-on: ubuntu-latest
needs: setup
env:
Expand All @@ -66,4 +66,4 @@ jobs:

- name: Run ${{matrix.adapter}} Tests
run: |
docker compose exec tests php ./vendor/bin/phpunit /app/tests/Migration/E2E/Sources/${{matrix.adapter}}Test.php
docker compose exec tests php ./vendor/bin/phpunit /app/tests/Migration/Unit/Sources/${{matrix.adapter}}Test.php
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ RUN set -ex \
&& docker-php-ext-install pdo pdo_pgsql \
&& apt-get remove -y libpq-dev

## Install XDebug, Remove before commit.
RUN \
git clone --depth 1 --branch 3.3.1 https://github.com/xdebug/xdebug && \
cd xdebug && \
phpize && \
./configure && \
make && make install

# Enable Extensions
COPY dev/xdebug.ini /usr/src/code/dev/xdebug.ini
RUN cp /usr/src/code/dev/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini

COPY ./src /app/src
COPY ./tests /app/src/tests
COPY --from=composer /usr/local/src/vendor /app/vendor
Expand Down
6 changes: 6 additions & 0 deletions dev/xdebug.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
zend_extension=xdebug

[xdebug]
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
xdebug.start_with_request=yes
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
## Tests
tests:
image: migrations-dev
image: migration-tests
build:
context: .
target: tests
Expand All @@ -22,6 +22,7 @@ services:

## Supabase
supabase-db:
image: migration-supabase
build:
context: .
target: supabase-db
Expand All @@ -44,6 +45,7 @@ services:

## NHost
nhost-db:
image: migration-nhost
build:
context: .
target: nhost-db
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
stopOnFailure="false"
>
<testsuites>
<testsuite name="E2E">
<directory>./tests/Migration/E2E</directory>
<testsuite name="Unit">
<directory>./tests/Migration/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
16 changes: 16 additions & 0 deletions src/Migration/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,20 @@ public function getReport(string $statusLevel = ''): array

return $report;
}

/**
* Get Source
*/
public function getSource(): Source
{
return $this->source;
}

/**
* Get Destination
*/
public function getDestination(): Destination
{
return $this->destination;
}
}
156 changes: 0 additions & 156 deletions tests/Migration/E2E/Sources/AppwriteTest.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Utopia\Tests\E2E\Adapters;
namespace Utopia\Tests\Unit\Adapters;

use Utopia\Migration\Destination;
use Utopia\Migration\Resource;
Expand Down Expand Up @@ -37,19 +37,22 @@ public static function getSupportedResources(): array
public function import(array $resources, callable $callback): void
{
foreach ($resources as $resource) {
/** @var resource $resource */
/** @var Resource $resource */
switch ($resource->getName()) {
case 'Deployment':
/** @var Deployment $resource */
if ($resource->getStart() === 0) {
$this->data[$resource->getGroup()][$resource->getName()][$resource->getInternalId()] = $resource->asArray();
$this->data[$resource->getName()][$resource->getInternalId()] = $resource->asArray();
}

// file_put_contents($this->path . 'deployments/' . $resource->getId() . '.tar.gz', $resource->getData(), FILE_APPEND);
break;
case Resource::TYPE_FILE:
/** @var File $resource */
break;
default:
$this->data[$resource->getName()][$resource->getId()] = $resource->asArray();
break;
}

$resource->setStatus(Resource::STATUS_SUCCESS);
Expand All @@ -63,4 +66,17 @@ public function report(array $groups = []): array
{
return [];
}

public function get(string $resource, string $id): ?array
{
if (!key_exists($resource, $this->data)) {
return null;
}

if (!key_exists($id, $this->data[$resource])) {
return null;
}

return $this->data[$resource][$id];
}
}
Loading

0 comments on commit 75ec3cc

Please sign in to comment.