diff --git a/scripts/commands/remove.sh b/scripts/commands/remove.sh new file mode 100644 index 0000000..8757129 --- /dev/null +++ b/scripts/commands/remove.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env sh + +set -eu + +remove_usage() { + cat <"$(_repository_scheme_file "${scheme_name}")" } +repository_delete_scheme() { + rm -f "$(_repository_scheme_file "${1}")" +} + repository_scheme_append_file_uri() { scheme_name="${1}" file_uri="${2}" diff --git a/tests/lib/asserts-config-repository.bash b/tests/lib/asserts-config-repository.bash index 4e25059..5a0f524 100644 --- a/tests/lib/asserts-config-repository.bash +++ b/tests/lib/asserts-config-repository.bash @@ -1,7 +1,14 @@ +assert_config_repository_scheme_not_exist() { + file="${HELM_CONFIG_SCHEME_REPOSITORY}/${1}" + + assert_file_not_exist "${file}" +} + assert_config_repository_scheme() { file="${HELM_CONFIG_SCHEME_REPOSITORY}/${1}" assert_file_exist "${file}" assert_equal "$(cat "${file}")" "${2}" } + diff --git a/tests/unit/remove.bats b/tests/unit/remove.bats index 7218444..881fe44 100644 --- a/tests/unit/remove.bats +++ b/tests/unit/remove.bats @@ -4,9 +4,53 @@ load '../lib/helper' load '../bats/extensions/bats-support/load' load '../bats/extensions/bats-assert/load' load '../bats/extensions/bats-file/load' +load '../lib/asserts-config-repository' -@test "remove:" { +@test "remove: show help" { run helm config-scheme remove + + assert_failure 1 + assert_output --partial 'helm config-scheme remove NAME' +} + +@test "remove -h: show help" { + run helm config-scheme remove -h + + assert_success + assert_output --partial 'helm config-scheme remove NAME' +} + +@test "remove --help: show help" { + run helm config-scheme remove --help + + assert_success + assert_output --partial 'helm config-scheme remove NAME' +} + +@test "remove help: show help" { + run helm config-scheme remove help + + assert_success + assert_output --partial 'helm config-scheme remove NAME' +} + +@test "remove scheme: show error if not exists" { + helm config-scheme add scheme1 a.yaml + helm config-scheme add scheme2 a.yaml b.yaml + + run helm config-scheme remove bob + assert_failure 2 - assert_output --partial 'Error: Not yet implemented.' + assert_output --partial "[config-scheme][remove] Scheme 'bob' doesn't exists" +} + +@test "remove scheme: remove the scheme" { + helm config-scheme add scheme1 a.yaml + helm config-scheme add scheme2 a.yaml b.yaml + + run helm config-scheme remove scheme1 + + assert_success + assert_config_repository_scheme_not_exist "scheme1" + assert_config_repository_scheme "scheme2" $'a.yaml\nb.yaml' }