Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod committed Oct 8, 2020
1 parent 3b207d4 commit 8f96244
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/infection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
run: composer install --prefer-dist --no-progress --no-suggest

- name: Run Infection
run: vendor/bin/infection --min-msi=86 --min-covered-msi=90 --log-verbosity=none -s
run: vendor/bin/infection --min-msi=88 --min-covered-msi=90 --log-verbosity=none -s
env:
INFECTION_BADGE_API_KEY: ${{ secrets.INFECTION_BADGE_API_KEY }}
2 changes: 1 addition & 1 deletion src/Snippet/Parts.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Parts
/** @return array<array<string, mixed>> */
public static function run(ClickHouseClient $clickHouseClient, string $table, ?bool $active = null) : array
{
$whereActiveClause = $active === null ? '' : sprintf(' AND active = %s', (int) $active);
$whereActiveClause = $active === null ? '' : sprintf(' AND active = %d', $active);

/** @var JsonEachRow<array<string, mixed>> $format */
$format = new JsonEachRow();
Expand Down
2 changes: 1 addition & 1 deletion src/Snippet/ShowCreateTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public static function run(ClickHouseClient $clickHouseClient, string $tableName
$format
);

return trim($output->data[0]['statement']);
return $output->data[0]['statement'];
}
}
30 changes: 29 additions & 1 deletion tests/Snippet/TableSizesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace SimPod\ClickHouseClient\Tests\Snippet;

use DateTimeImmutable;
use SimPod\ClickHouseClient\Snippet\TableSizes;
use SimPod\ClickHouseClient\Tests\TestCaseBase;
use SimPod\ClickHouseClient\Tests\WithClient;
Expand All @@ -13,8 +14,35 @@ final class TableSizesTest extends TestCaseBase
{
use WithClient;

public function setUp() : void
{
$this->client->executeQuery(
<<<CLICKHOUSE
CREATE TABLE test (
a_date DateTime,
value Int8
)
ENGINE = MergeTree
PARTITION BY toDate(a_date)
ORDER BY (value)
CLICKHOUSE
);
}

public function testRun() : void
{
self::assertSame([], TableSizes::run($this->client));
$this->client->insert('test', [[new DateTimeImmutable(), 1]]);

self::assertCount(1, TableSizes::run($this->client));
}

public function testRunOnNonexistentDatabase() : void
{
self::assertSame([], TableSizes::run($this->client, 'does not exist'));
}

public function tearDown() : void
{
$this->client->executeQuery('DROP TABLE test');
}
}

0 comments on commit 8f96244

Please sign in to comment.