Skip to content

Commit

Permalink
use json config file instead yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrajodas committed Dec 28, 2020
1 parent bfa2a09 commit cea9d13
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 100 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"monolog/monolog": "^2.2",
"pimple/pimple": "^3.3",
"symfony/config": "^5.2",
"symfony/process": "^5.2",
"symfony/yaml": "^5.2"
"symfony/process": "^5.2"
},
"require-dev": {
"keboola/coding-standard": ">=7.0.2",
Expand Down
74 changes: 1 addition & 73 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions run.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
use Keboola\GoogleDriveExtractor\Exception\ApplicationException;
use Keboola\GoogleDriveExtractor\Exception\UserException;
use Keboola\GoogleDriveExtractor\Logger;
use Symfony\Component\Yaml\Yaml;

require_once(dirname(__FILE__) . "/bootstrap.php");

Expand All @@ -15,7 +14,7 @@
if (!isset($arguments["data"])) {
throw new UserException('Data folder not set.');
}
$config = Yaml::parse(file_get_contents($arguments["data"] . "/config.yml"));
$config = json_decode(file_get_contents($arguments["data"] . "/config.json"), true);
$config['parameters']['data_dir'] = $arguments['data'];

$app = new Application($config);
Expand Down
3 changes: 1 addition & 2 deletions src/Keboola/GoogleDriveExtractor/Extractor/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Keboola\GoogleDriveExtractor\Extractor;

use Keboola\Csv\CsvWriter;
use Symfony\Component\Yaml\Yaml;

class Output
{
Expand Down Expand Up @@ -80,7 +79,7 @@ public function createManifest(string $filename, string $outputTable): bool
'incremental' => false,
];

return (bool) file_put_contents($outFilename, Yaml::dump($manifestData));
return (bool) file_put_contents($outFilename, json_encode($manifestData));
}

protected function normalizeCsvHeader(array $header): array
Expand Down
3 changes: 1 addition & 2 deletions tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Keboola\GoogleDriveExtractor\Application;
use Keboola\GoogleDriveExtractor\Exception\UserException;
use Symfony\Component\Yaml\Yaml;

class ApplicationTest extends BaseTest
{
Expand All @@ -30,7 +29,7 @@ public function testAppRun(): void
);

$manifestPath = $outputPath . '.manifest';
$manifest = Yaml::parse((string) file_get_contents($manifestPath));
$manifest = json_decode((string) file_get_contents($manifestPath), true);

$this->assertArrayHasKey('destination', $manifest);
$this->assertArrayHasKey('incremental', $manifest);
Expand Down
6 changes: 3 additions & 3 deletions tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Keboola\Google\ClientBundle\Google\RestApi;
use Keboola\GoogleDriveExtractor\GoogleDrive\Client;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Yaml\Yaml;
use \Throwable;

abstract class BaseTest extends TestCase
{
Expand Down Expand Up @@ -43,7 +43,7 @@ protected function prepareTestFile(string $path, string $name): array

protected function makeConfig(array $testFile): array
{
$config = Yaml::parse((string) file_get_contents(__DIR__ . '/data/config.yml'));
$config = json_decode((string) file_get_contents(__DIR__ . '/data/config.json'), true);
$config['parameters']['data_dir'] = __DIR__ . '/data';
$config['authorization']['oauth_api']['credentials'] = [
'appKey' => getenv('CLIENT_ID'),
Expand Down Expand Up @@ -72,7 +72,7 @@ public function tearDown(): void
{
try {
$this->googleDriveApi->deleteFile($this->testFile['id']);
} catch (\Throwable $e) {
} catch (Throwable $e) {
}
}

Expand Down
4 changes: 1 addition & 3 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Keboola\Csv\CsvWriter;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
use Symfony\Component\Yaml\Yaml;

class FunctionalTest extends BaseTest
{
Expand Down Expand Up @@ -139,8 +138,7 @@ private function runProcess(): Process
$fs->mkdir($this->dataPath);
$fs->mkdir($this->dataPath . '/out/tables');

$yaml = new Yaml();
file_put_contents($this->dataPath . '/config.yml', $yaml->dump($this->config));
file_put_contents($this->dataPath . '/config.json', json_encode($this->config));

$process = Process::fromShellCommandline(sprintf('php run.php --data=%s', $this->dataPath));
$process->run();
Expand Down
19 changes: 19 additions & 0 deletions tests/data/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"parameters": {
"outputBucket": "in.c-google-drive-extractor-testcfg1",
"sheets": [
{
"id": 0,
"fileId": null,
"fileTitle": null,
"sheetId": null,
"sheetTitle": null,
"outputTable": null,
"enabled": true,
"header": {
"rows": 1
}
}
]
}
}
13 changes: 0 additions & 13 deletions tests/data/config.yml

This file was deleted.

0 comments on commit cea9d13

Please sign in to comment.