Skip to content

Commit

Permalink
Merge pull request #25 from keboola/COM-859-ondra-snflk-in-azure-stack
Browse files Browse the repository at this point in the history
Used different snlfk writer on Azure stacks
  • Loading branch information
ondrajodas authored Jul 13, 2021
2 parents 57472a6 + f97a61c commit aa29fa6
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/DbBackend/SnowflakeBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

class SnowflakeBackend implements DbBackend
{
public const COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE = 'keboola.wr-db-snowflake';
public const COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_S3 = 'keboola.wr-db-snowflake';

public const COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_ABS = 'keboola.wr-snowflake-blob-storage';

private Config $config;

Expand Down Expand Up @@ -56,7 +58,14 @@ public function createDbConnectionApiObject(string $connectionName): DBConnectio

public function getWriterComponentName(): string
{
return self::COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE;
switch ($this->config->getStorageApiUrl()) {
case 'connection.north-europe.azure.keboola.com':
case 'connection.csas.keboola.cloud':
case 'connection.csas-test.keboola.com':
return self::COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_ABS;
default:
return self::COMPONENT_KEBOOLA_WR_DB_SNOWFLAKE_S3;
}
}

public function getTestConnectionConfig(): ?array
Expand Down
54 changes: 54 additions & 0 deletions tests/phpunit/DbBeckend/SnowflakeBackendTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

declare(strict_types=1);

namespace Keboola\LookerWriter\Tests\DbBeckend;

use Generator;
use Keboola\LookerWriter\Config;
use Keboola\LookerWriter\ConfigDefinition\RunConfigDefinition;
use Keboola\LookerWriter\DbBackend\SnowflakeBackend;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;

class SnowflakeBackendTest extends TestCase
{
/** @dataProvider componentNameDataProvider */
public function testComponentName(string $storageUrl, string $expectedComponentId): void
{
putenv('KBC_URL=' . $storageUrl);
$config = new Config([], new RunConfigDefinition());

$snflkBackend = new SnowflakeBackend($config);

Assert::assertEquals($expectedComponentId, $snflkBackend->getWriterComponentName());
}

public function componentNameDataProvider(): Generator
{
yield 'azure-ne' => [
'connection.north-europe.azure.keboola.com',
'keboola.wr-snowflake-blob-storage',
];

yield 'azure-csas-prod' => [
'connection.csas.keboola.cloud',
'keboola.wr-snowflake-blob-storage',
];

yield 'azure-csas-test' => [
'connection.csas-test.keboola.com',
'keboola.wr-snowflake-blob-storage',
];

yield 'aws-us' => [
'connection.keboola.com',
'keboola.wr-db-snowflake',
];

yield 'aws-eu' => [
'connection.eu-central-1.keboola.com',
'keboola.wr-db-snowflake',
];
}
}

0 comments on commit aa29fa6

Please sign in to comment.