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
|
//CommandUnset implements config:unset
|
||||||
func CommandUnset(args []string, global bool, noRestart bool) {
|
func CommandUnset(args []string, global bool, noRestart bool) {
|
||||||
appName, keys := getCommonArgs(global, args)
|
appName, keys := getCommonArgs(global, args)
|
||||||
|
if len(keys) == 0 {
|
||||||
|
common.LogFail("At least one key must be given")
|
||||||
|
}
|
||||||
err := UnsetMany(appName, keys, !noRestart)
|
err := UnsetMany(appName, keys, !noRestart)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
common.LogFail(err.Error())
|
common.LogFail(err.Error())
|
||||||
@@ -71,6 +74,9 @@ func CommandUnset(args []string, global bool, noRestart bool) {
|
|||||||
//CommandSet implements config:set
|
//CommandSet implements config:set
|
||||||
func CommandSet(args []string, global bool, noRestart bool, encoded bool) {
|
func CommandSet(args []string, global bool, noRestart bool, encoded bool) {
|
||||||
appName, pairs := getCommonArgs(global, args)
|
appName, pairs := getCommonArgs(global, args)
|
||||||
|
if len(pairs) == 0 {
|
||||||
|
common.LogFail("At least one env pair must be given")
|
||||||
|
}
|
||||||
updated := make(map[string]string)
|
updated := make(map[string]string)
|
||||||
for _, e := range pairs {
|
for _, e := range pairs {
|
||||||
parts := strings.SplitN(e, "=", 2)
|
parts := strings.SplitN(e, "=", 2)
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ teardown() {
|
|||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
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"
|
run /bin/bash -c "dokku config:get $TEST_APP test_var1 | grep true"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
@@ -88,6 +94,11 @@ teardown() {
|
|||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_success
|
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"
|
run /bin/bash -c "dokku --app $TEST_APP config:get test_var1 | grep true"
|
||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
@@ -128,6 +139,11 @@ teardown() {
|
|||||||
echo "output: $output"
|
echo "output: $output"
|
||||||
echo "status: $status"
|
echo "status: $status"
|
||||||
assert_output ""
|
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)" {
|
@test "(config) global config (herokuish)" {
|
||||||
|
|||||||
Reference in New Issue
Block a user