Skip to content

Commit

Permalink
Merge pull request #1390 from keboola/zajca-ct-1693
Browse files Browse the repository at this point in the history
CT-1693 testRefreshTablesInformation test alias update
  • Loading branch information
zajca committed Aug 21, 2024
2 parents 8ec3b5a + cd78fec commit 4ed66bc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
24 changes: 10 additions & 14 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,21 @@ parameters:
count: 1
path: src/Keboola/StorageApi/Client.php

-
message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:validateColumnNames\\(\\) has no return type specified\\.$#"
count: 1
path: src/Keboola/StorageApi/Client.php

-
message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:waitForJob\\(\\) has parameter \\$jobId with no type specified\\.$#"
count: 1
path: src/Keboola/StorageApi/Client.php

-
message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:webalizeColumnNames\\(\\) has no return type specified\\.$#"
count: 1
path: src/Keboola/StorageApi/Client.php

-
message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:webalizeDisplayName\\(\\) has no return type specified\\.$#"
count: 1
Expand Down Expand Up @@ -2510,11 +2520,6 @@ parameters:
count: 1
path: tests/Backend/Export/ExportParamsTest.php

-
message: "#^Unreachable statement \\- code above always terminates\\.$#"
count: 1
path: tests/Backend/ExternalBuckets/SnowflakeBucketsRefreshTablesInformationTest.php

-
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
count: 1
Expand Down Expand Up @@ -5224,12 +5229,3 @@ parameters:
message: "#^Parameter \\#1 \\$filename of function file_get_contents expects string, string\\|false given\\.$#"
count: 1
path: tests/bootstrap.php
-
message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:webalizeColumnNames\\(\\) has no return type specified\\.$#"
count: 1
path: src/Keboola/StorageApi/Client.php

-
message: "#^Method Keboola\\\\StorageApi\\\\Client\\:\\:validateColumnNames\\(\\) has no return type specified\\.$#"
count: 1
path: src/Keboola/StorageApi/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function testRefreshTablesInformationEndpointExists(): void

public function testRefreshTablesInformation(): void
{
$this->markTestSkipped('Test is not working, needs to be fixed; CT-1691');
$createdTableRows = 10;

$workspaces = new Workspaces($this->_client);
Expand All @@ -41,6 +40,7 @@ public function testRefreshTablesInformation(): void
$bucket = $this->_client->getBucket($bucketId);

$tableId = $this->createTableWithRandomData('refresh-tables-information-test-table', $createdTableRows, 2);
$aliasId = $this->_client->createAliasTable($bucketId, $tableId, 'alias');
$table = $this->_client->getTable($tableId);

$rowsCount = $table['rowsCount'];
Expand All @@ -58,6 +58,13 @@ public function testRefreshTablesInformation(): void
),
);

$db->executeQuery(
sprintf(
'USE ROLE %s;',
SnowflakeQuote::quoteSingleIdentifier($workspace['connection']['database']),
),
);

$db->executeQuery(
sprintf(
'USE WAREHOUSE %s;',
Expand All @@ -81,7 +88,7 @@ public function testRefreshTablesInformation(): void

$db->executeQuery(
sprintf(
'INSERT INTO %s ("col_1","col_2") VALUES (\'testvalue 1\', \'testvalue 2\')',
'INSERT INTO %s ("col_1","col_2") VALUES (\'testvalue 1\', \'testvalue 2\'),(\'testvalue 1\', \'testvalue 2\')',
SnowflakeQuote::quoteSingleIdentifier($table['name']),
),
);
Expand All @@ -91,15 +98,25 @@ public function testRefreshTablesInformation(): void
$bClient->refreshTableInformationInBucket($bucketId);

$refreshedTable = $this->_client->getTable($tableId);
$refreshedTableAlias = $this->_client->getTable($aliasId);

$this->assertEquals($rowsCount + 1, $refreshedTable['rowsCount']);
$this->assertEquals($rowsCount + 2, $refreshedTable['rowsCount']);
$this->assertEquals($refreshedTable['rowsCount'], $refreshedTableAlias['rowsCount']);
// TODO: check dataSizeBytes did not change but rowsCount did
// $this->assertNotEquals($dataSizeBytes, $refreshedTable['dataSizeBytes']);
// $this->assertNotEquals($refreshedTable['dataSizeBytes'], $refreshedTableAlias['dataSizeBytes']);

$this->_client->dropTable($tableId);
$this->_client->dropTable($tableId, ['force' => true]);
$this->_client->dropBucket($bucketId);
$workspaces->deleteWorkspace($workspace['id']);

$db->executeQuery(
sprintf(
'USE ROLE %s;',
SnowflakeQuote::quoteSingleIdentifier((string) getenv('SNOWFLAKE_USER')),
),
);

$db->executeQuery(
sprintf(
'REVOKE ROLE %s FROM USER %s;',
Expand Down

0 comments on commit 4ed66bc

Please sign in to comment.