Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
odinuv committed Sep 13, 2024
1 parent 706bf8e commit 6e0bfec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ protected function getWorkspace(): StorageApiWorkspace

public function cleanup(): void
{
if (!empty($this->workspace)) {
$this->workspacesApiClient->deleteWorkspace((int) $this->getWorkspaceId(), [], true);
}
$this->workspacesApiClient->deleteWorkspace((int) $this->getWorkspaceId(), [], true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,25 +106,42 @@ public function testCleanupDeletedWorkspaceStaging(): void
$workspaceId,
DatabaseWorkspaceCredentials::fromPasswordResetArray(['password' => 'test']),
);
self::assertSame($workspaceId, $workspaceProvider->getWorkspaceId()); // Ensure workspace is initialized
self::assertSame($workspaceId, $workspaceProvider->getWorkspaceId());
$workspaceProvider->cleanup();
}

public function testCleanupDeletedWorkspaceStagingNotInitialized(): void
{
$workspaceId = '1';

$workspacesApiClient = $this->createMock(Workspaces::class);
$workspacesApiClient
->expects(self::never())
->method('deleteWorkspace');
->expects(self::once())
->method('deleteWorkspace')
->with($workspaceId, [], true);
$workspacesApiClient
->expects(self::never())
->method('getWorkspace');
->expects(self::once())
->method('getWorkspace')
->with($workspaceId)
->willReturn([
'id' => $workspaceId,
'backendSize' => 'large',
'connection' => [
'backend' => 'snowflake',
'host' => 'some-host',
'warehouse' => 'some-warehouse',
'database' => 'some-database',
'schema' => 'some-schema',
'user' => 'some-user',
],
]);

$workspaceProvider = new ExistingWorkspaceStagingProvider(
$workspacesApiClient,
'1234',
$workspaceId,
DatabaseWorkspaceCredentials::fromPasswordResetArray(['password' => 'test']),
);
// the workspace is cleaned event if "not initialized" (no getWorkspaceId called)
$workspaceProvider->cleanup();
}

Expand Down

0 comments on commit 6e0bfec

Please sign in to comment.