From db4e66116fc5067811623a7eb85e243f268796c2 Mon Sep 17 00:00:00 2001 From: SmetDenis Date: Mon, 9 Jul 2018 12:11:17 +0300 Subject: [PATCH] key to upper --- README.md | 6 +++--- src/KeyRestoreCommand.php | 2 ++ tests/KeyKeeperTest.php | 10 ++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ad66772..a8c0f94 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ ```sh -teamcity-keykeeper key:save --name="some_key_name" --value="some_value"; -teamcity-keykeeper key:restore --name="some_key_name"; +teamcity-keykeeper key:save --name="some_env_var_name" --value="some_value"; +teamcity-keykeeper key:restore --all; ``` Output ```sh -##teamcity[setParameter name='env.some_key_name' value='some_value'] +##teamcity[setParameter name='env.SOME_ENV_VAR_NAME' value='some_value'] ``` diff --git a/src/KeyRestoreCommand.php b/src/KeyRestoreCommand.php index fbca1df..05edd10 100644 --- a/src/KeyRestoreCommand.php +++ b/src/KeyRestoreCommand.php @@ -48,9 +48,11 @@ protected function execute(InputInterface $input, OutputInterface $output) if (!$input->getOption('all')) { $name = trim($input->getOption('name')); $value = $storage->get($name); + $name = strtoupper($name); $output->writeln("##teamcity[setParameter name='env.{$name}' value='{$value}']"); } else { foreach ($storage->getArrayCopy() as $name => $value) { + $name = strtoupper($name); $output->writeln("##teamcity[setParameter name='env.{$name}' value='{$value}']"); } } diff --git a/tests/KeyKeeperTest.php b/tests/KeyKeeperTest.php index 3219360..9989283 100644 --- a/tests/KeyKeeperTest.php +++ b/tests/KeyKeeperTest.php @@ -41,6 +41,7 @@ public function testSaveAndRestoreKey() isContain("Key '{$name}' saved", $saveResult); $restoreResult = trim(Cli::exec("php {$bin} key:restore --name='{$name}'")); + $name = strtoupper($name); isSame("##teamcity[setParameter name='env.{$name}' value='{$value}']", $restoreResult); } @@ -54,6 +55,7 @@ public function testSpecialChars() isContain("Key '{$name}' saved", $saveResult); $restoreResult = trim(Cli::exec("php {$bin} key:restore --name='{$name}'")); + $name = strtoupper($name); isSame("##teamcity[setParameter name='env.{$name}' value='{$value}']", $restoreResult); } @@ -65,8 +67,8 @@ public function testGetAllKeys() Cli::exec("php {$bin} key:save --name='key2' --value='value2'"); $restoreResult = trim(Cli::exec("php {$bin} key:restore --all")); - isContain("##teamcity[setParameter name='env.key1' value='value1']", $restoreResult); - isContain("##teamcity[setParameter name='env.key2' value='value2']", $restoreResult); + isContain("##teamcity[setParameter name='env.KEY1' value='value1']", $restoreResult); + isContain("##teamcity[setParameter name='env.KEY2' value='value2']", $restoreResult); } public function testRemoveKeysWithOption() @@ -77,7 +79,7 @@ public function testRemoveKeysWithOption() Cli::exec("php {$bin} key:save --name='key' --value=''"); $restoreResult = trim(Cli::exec("php {$bin} key:restore --all")); - isContain("##teamcity[setParameter name='env.key' value='']", $restoreResult); + isContain("##teamcity[setParameter name='env.KEY' value='']", $restoreResult); } public function testRemoveKeysWithoutOption() @@ -88,6 +90,6 @@ public function testRemoveKeysWithoutOption() Cli::exec("php {$bin} key:save --name='key'"); $restoreResult = trim(Cli::exec("php {$bin} key:restore --all")); - isContain("##teamcity[setParameter name='env.key' value='']", $restoreResult); + isContain("##teamcity[setParameter name='env.KEY' value='']", $restoreResult); } }