Skip to content

Commit 4d92ed8

Browse files
committed
test[input-mapping,output-mapping]: Fix tests after StagingProvider class cleanup
1 parent 716ae46 commit 4d92ed8

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

tests/AbstractTestCase.php

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Keboola\StagingProvider\Staging\File\FileStagingInterface;
1212
use Keboola\StagingProvider\Staging\StagingProvider;
1313
use Keboola\StagingProvider\Staging\StagingType;
14-
use Keboola\StagingProvider\Staging\Workspace\WorkspaceStagingInterface;
1514
use Keboola\StorageApi\Client;
1615
use Keboola\StorageApi\ClientException;
1716
use Keboola\StorageApi\Options\ListFilesOptions;
@@ -169,39 +168,26 @@ protected function getWorkspaceStagingFactory(
169168
?LoggerInterface $logger = null,
170169
StagingType $stagingType = StagingType::WorkspaceSnowflake,
171170
): StrategyFactory {
172-
$workspaceStaging = $this->createMock(WorkspaceStagingInterface::class);
173-
$workspaceStaging->method('getWorkspaceId')->willReturnCallback(
174-
function () use ($stagingType, $clientWrapper) {
175-
if (!$this->workspaceId) {
176-
$workspaces = new Workspaces($clientWrapper->getBranchClient());
177-
$workspace = $workspaces->createWorkspace(['backend' => match ($stagingType) {
178-
StagingType::WorkspaceSnowflake => 'snowflake',
179-
StagingType::WorkspaceBigquery => 'bigquery',
180-
default => throw new InvalidArgumentException(sprintf(
181-
'Unknown staging %s',
182-
$stagingType->value,
183-
)),
184-
}], true);
185-
$this->workspaceId = (string) $workspace['id'];
186-
$this->workspaceCredentials = $workspace['connection'];
187-
$this->workspaceClient = $workspaces;
188-
}
189-
return $this->workspaceId;
190-
},
191-
);
192-
193-
$fileStaging = $this->createMock(FileStagingInterface::class);
194-
$fileStaging->method('getPath')->willReturnCallback(
195-
function () {
196-
return $this->temp->getTmpFolder();
197-
},
198-
);
171+
if (!$this->workspaceId) {
172+
$workspaces = new Workspaces($clientWrapper->getBranchClient());
173+
$workspace = $workspaces->createWorkspace(['backend' => match ($stagingType) {
174+
StagingType::WorkspaceSnowflake => 'snowflake',
175+
StagingType::WorkspaceBigquery => 'bigquery',
176+
default => throw new InvalidArgumentException(sprintf(
177+
'Unknown staging %s',
178+
$stagingType->value,
179+
)),
180+
}], true);
181+
$this->workspaceId = (string) $workspace['id'];
182+
$this->workspaceCredentials = $workspace['connection'];
183+
$this->workspaceClient = $workspaces;
184+
}
199185

200186
return new StrategyFactory(
201187
new StagingProvider(
202-
$stagingType,
203-
$workspaceStaging,
204-
$fileStaging,
188+
stagingType: $stagingType,
189+
localStagingPath: $this->temp->getTmpFolder(),
190+
stagingWorkspaceId: $this->workspaceId,
205191
),
206192
$clientWrapper,
207193
$logger ?: new NullLogger(),
@@ -225,8 +211,8 @@ function () {
225211
return new StrategyFactory(
226212
new StagingProvider(
227213
stagingType: $stagingType,
228-
workspaceStaging: null,
229-
localStaging: $fileStaging,
214+
localStagingPath: $this->temp->getTmpFolder(),
215+
stagingWorkspaceId: null,
230216
),
231217
$clientWrapper,
232218
$logger ?: new NullLogger(),

tests/ReaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ function () {
4242
return new StrategyFactory(
4343
new StagingProvider(
4444
stagingType: $stagingType,
45-
workspaceStaging: null,
46-
localStaging: $localStaging,
45+
localStagingPath: $this->temp->getTmpFolder(),
46+
stagingWorkspaceId: null,
4747
),
4848
$clientWrapper,
4949
$logger ?: new NullLogger(),

0 commit comments

Comments
 (0)