mirror of
https://github.com/dokku/dokku.git
synced 2025-12-28 16:06:40 +01:00
Merge pull request #3614 from alexquick/fix-3606
[config] validate args for config:set and config:unset
This commit is contained in:
@@ -62,6 +62,9 @@ func CommandClear(args []string, global bool, noRestart bool) {
|
||||
//CommandUnset implements config:unset
|
||||
func CommandUnset(args []string, global bool, noRestart bool) {
|
||||
appName, keys := getCommonArgs(global, args)
|
||||
if len(keys) == 0 {
|
||||
common.LogFail("At least one key must be given")
|
||||
}
|
||||
err := UnsetMany(appName, keys, !noRestart)
|
||||
if err != nil {
|
||||
common.LogFail(err.Error())
|
||||
@@ -71,6 +74,9 @@ func CommandUnset(args []string, global bool, noRestart bool) {
|
||||
//CommandSet implements config:set
|
||||
func CommandSet(args []string, global bool, noRestart bool, encoded bool) {
|
||||
appName, pairs := getCommonArgs(global, args)
|
||||
if len(pairs) == 0 {
|
||||
common.LogFail("At least one env pair must be given")
|
||||
}
|
||||
updated := make(map[string]string)
|
||||
for _, e := range pairs {
|
||||
parts := strings.SplitN(e, "=", 2)
|
||||
|
||||
@@ -69,6 +69,12 @@ teardown() {
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku config:set $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "FAILED: At least one env pair must be given"
|
||||
[ "$status" -eq 1 ]
|
||||
|
||||
run /bin/bash -c "dokku config:get $TEST_APP test_var1 | grep true"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
@@ -88,6 +94,11 @@ teardown() {
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
run /bin/bash -c "dokku --app $TEST_APP config:set"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "FAILED: At least one env pair must be given"
|
||||
[ "$status" -eq 1 ]
|
||||
|
||||
run /bin/bash -c "dokku --app $TEST_APP config:get test_var1 | grep true"
|
||||
echo "output: $output"
|
||||
@@ -128,6 +139,11 @@ teardown() {
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output ""
|
||||
run /bin/bash -c "dokku config:unset $TEST_APP"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "FAILED: At least one key must be given"
|
||||
[ "$status" -eq 1 ]
|
||||
}
|
||||
|
||||
@test "(config) global config (herokuish)" {
|
||||
|
||||
Reference in New Issue
Block a user