Skip to content

Commit c731f0f

Browse files
committed
fix tests
1 parent cb3b6e9 commit c731f0f

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

tests/Backend/Workspaces/WorkspacesCredentialsTest.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ public function setUp(): void
2121
{
2222
parent::setUp();
2323

24-
$this->allowTestForBackendsOnly(['snowflake', 'bigquery'], 'Workspace credentials are implemented only for Snowflake and BigQuery');
24+
$this->allowTestForBackendsOnly([
25+
'snowflake',
26+
'bigquery',
27+
], 'Workspace credentials are implemented only for Snowflake and BigQuery');
2528
}
2629

2730
public function testConnectByCredentials(): void
2831
{
2932
$this->skipTestForBackend(['bigquery'], 'BigQuery is WIP');
3033

3134
// create workspace and source table in workspace
32-
$workspace = $this->initTestWorkspace();
35+
$workspace = $this->initTestWorkspace(forceRecreate: true);
3336

3437
// connect to workspace after creation (we have credentials in response)
3538
$backend = WorkspaceBackendFactory::createWorkspaceBackend($workspace);
@@ -60,18 +63,17 @@ public function testConnectByCredentials(): void
6063

6164
$workspaces = new Workspaces($this->workspaceSapiClient);
6265

63-
$this->initEvents($this->_client);
66+
$this->initEvents($this->workspaceSapiClient);
6467
// credentials creation
6568
$assertCallback = function ($events) {
6669
$this->assertCount(1, $events);
6770
};
6871

6972
$query = new EventsQueryBuilder();
70-
$query->setEvent('storage.workspaceCredentialsCreated')
71-
->setTokenId($this->tokenId);
72-
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
73+
$query->setEvent('storage.workspaceCredentialsCreated')->setTokenId($this->tokenId);
7374

7475
$workspaceCredentials = $workspaces->createCredentials($workspace['id']);
76+
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
7577
$workspaceBackend = WorkspaceBackendFactory::createWorkspaceBackend($workspaceCredentials, true);
7678

7779
$dbResult = $workspaceBackend->fetchAll('test_Languages');
@@ -80,27 +82,26 @@ public function testConnectByCredentials(): void
8082
[
8183
0 => [1, 'cz'],
8284
1 => [2, 'en'],
83-
],
85+
],
8486
$dbResult,
8587
);
8688

8789
// should just return the same credentials
8890
$query = new EventsQueryBuilder();
89-
$query->setEvent('storage.workspaceCredentialsRetrieved')
90-
->setTokenId($this->tokenId);
91-
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
91+
$query->setEvent('storage.workspaceCredentialsRetrieved')->setTokenId($this->tokenId);
92+
9293
$retrievedCredentials = $workspaces->createCredentials($workspace['id']);
93-
$this->assertEquals($workspaceCredentials['connection']['private_key'], $retrievedCredentials['connection']['private_key']);
94+
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
95+
$this->assertEquals($workspaceCredentials['connection']['privateKey'], $retrievedCredentials['connection']['privateKey']);
9496

9597
// credential detail is working and returning a correct object
9698
$credentialsId = $workspaceCredentials['connection']['credentials']['id'];
9799

98100
$query = new EventsQueryBuilder();
99-
$query->setEvent('storage.workspaceCredentialsDetail')
100-
->setTokenId($this->tokenId);
101-
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
101+
$query->setEvent('storage.workspaceCredentialsDetail')->setTokenId($this->tokenId);
102102
$workspaceCredentialsRefreshed = $workspaces->getCredentials($workspace['id'], $credentialsId);
103-
$this->assertEquals($workspaceCredentials['connection']['private_key'], $workspaceCredentialsRefreshed['connection']['private_key']);
103+
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
104+
$this->assertEquals($workspaceCredentials['connection']['privateKey'], $workspaceCredentialsRefreshed['connection']['privateKey']);
104105
$workspaceBackendRefreshed = WOrkspaceBackendFactory::createWorkspaceBackend($workspaceCredentialsRefreshed, true);
105106

106107
$dbResultRefreshed = $workspaceBackendRefreshed->fetchAll('test_Languages');
@@ -114,10 +115,9 @@ public function testConnectByCredentials(): void
114115
);
115116

116117
$query = new EventsQueryBuilder();
117-
$query->setEvent('storage.workspaceCredentialsDeleted')
118-
->setTokenId($this->tokenId);
119-
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
118+
$query->setEvent('storage.workspaceCredentialsDeleted')->setTokenId($this->tokenId);
120119
$workspaces->deleteCredentials($workspace['id'], $credentialsId);
120+
$this->assertEventWithRetries($this->_client, $assertCallback, $query);
121121

122122
try {
123123
WorkspaceBackendFactory::createWorkspaceBackend($workspaceCredentialsRefreshed, true);

0 commit comments

Comments
 (0)