From 6f6e624da60debff3f3aee3fe593699022c06736 Mon Sep 17 00:00:00 2001 From: rjpadilla Date: Mon, 22 Mar 2021 22:46:09 +0300 Subject: [PATCH 1/2] update config.bats (fixes #2119) --- tests/config.bats | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/config.bats diff --git a/tests/config.bats b/tests/config.bats new file mode 100644 index 0000000000..8799040f07 --- /dev/null +++ b/tests/config.bats @@ -0,0 +1,46 @@ +#!/usr/bin/env bats +load test-helper + +@test "$clinom config" { + skip "Run $clinom config with the [update|add|delete|clear] subcommands" + run "${clicmd}" config + [ "$status" -eq 0 ] +} + +@test "$clinom config update" { + run "${clicmd}" config update abc 123 + if [[ "$output" == *"Error"* ]]; then + skip "Missing varname or varvalue" + fi + assert_success +} + +@test "$clinom config add" { + run "${clicmd}" config add abc 123 + if [[ "$output" == *"Error"* ]]; then + skip "Missing varname or varvalue" + fi + assert_success +} + +@test "$clinom config delete" { + run "${clicmd}" config delete abc + if [[ "$output" == *"Error"* ]]; then + skip "Missing varname" + fi + assert_success +} + +@test "$clinom config delete (non-existent user)" { + run "${clicmd}" config clear + run "${clicmd}" config delete abc + if [[ "$output" == *"Error"* ]]; then + skip "Can't delete a non-existent user" + fi + assert_success +} + +@test "$clinom config clear" { + run "${clicmd}" config clear + assert_success +} \ No newline at end of file From 4236e5219b0522ccc1dea0e063ade8b14a0e54ef Mon Sep 17 00:00:00 2001 From: rjpadilla Date: Thu, 1 Apr 2021 00:38:55 +0300 Subject: [PATCH 2/2] update config.bats (fixes #2119) --- tests/config.bats | 48 +++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/tests/config.bats b/tests/config.bats index 8799040f07..0bfb051a68 100644 --- a/tests/config.bats +++ b/tests/config.bats @@ -1,46 +1,50 @@ #!/usr/bin/env bats load test-helper -@test "$clinom config" { - skip "Run $clinom config with the [update|add|delete|clear] subcommands" +@test "$clinom config (empty)" { + run "${clicmd}" config clear + run "${clicmd}" config + assert_output --partial 'config file is empty' +} + +@test "$clinom config (random subcommand)" { + run "${clicmd}" config random-command + assert_output --partial 'options are supported' +} + +@test "$clinom config (not empty)" { + run "${clicmd}" config add slack_apitoken xoxp-0000000000000-1111111111111-2222222222222 run "${clicmd}" config - [ "$status" -eq 0 ] + assert_success } @test "$clinom config update" { - run "${clicmd}" config update abc 123 - if [[ "$output" == *"Error"* ]]; then - skip "Missing varname or varvalue" - fi + run "${clicmd}" config update slack_apitoken xoxp-0000000000000-1111111111111-2222222222222 assert_success } @test "$clinom config add" { - run "${clicmd}" config add abc 123 - if [[ "$output" == *"Error"* ]]; then - skip "Missing varname or varvalue" - fi + run "${clicmd}" config add slack_apitoken xoxp-0000000000000-1111111111111-2222222222222 assert_success } +@test "$clinom config add (missing argument)" { + run "${clicmd}" config add + assert_output --partial 'missing varname or varvalue' +} + @test "$clinom config delete" { - run "${clicmd}" config delete abc - if [[ "$output" == *"Error"* ]]; then - skip "Missing varname" - fi - assert_success + run "${clicmd}" config delete slack_apitoken + assert_failure } @test "$clinom config delete (non-existent user)" { - run "${clicmd}" config clear - run "${clicmd}" config delete abc - if [[ "$output" == *"Error"* ]]; then - skip "Can't delete a non-existent user" - fi - assert_success + run "${clicmd}" config delete slack_apitoken + assert_output --partial "doesn't exist" } @test "$clinom config clear" { run "${clicmd}" config clear + [ ! -e /etc/treehouses.conf ] assert_success } \ No newline at end of file