mirror of
https://github.com/dokku/dokku.git
synced 2026-07-10 04:23:59 +02:00
Every Go-implemented plugin's `:report --format json` now emits keys without the redundant `<plugin>-` head segment, matching the shape bash plugins have always emitted. The CLI flag names and `:set` semantics are unchanged. For backwards compatibility during the 0.38.x patch series, the legacy `<plugin>-<property>` keys are emitted side-by-side with the new keys, and a future major release will drop the legacy keys. `common.ReportSingleApp` is refactored to accept a `ReportSingleAppInput` struct with a `Validate()` method so the input is checked before any work runs, which also catches the latent `"docker options"` reportType bug at the API boundary.
166 lines
5.3 KiB
Bash
166 lines
5.3 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup() {
|
|
global_setup
|
|
create_app
|
|
}
|
|
|
|
teardown() {
|
|
dokku scheduler:set --global selected >/dev/null 2>&1 || true
|
|
dokku scheduler:set --global shell >/dev/null 2>&1 || true
|
|
destroy_app
|
|
global_teardown
|
|
}
|
|
|
|
@test "(scheduler) scheduler:help" {
|
|
run /bin/bash -c "dokku scheduler"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "Manage scheduler settings"
|
|
help_output="$output"
|
|
|
|
run /bin/bash -c "dokku scheduler:help"
|
|
echo "output: $output"
|
|
echo "status: $status"
|
|
assert_output_contains "Manage scheduler settings"
|
|
assert_output "$help_output"
|
|
}
|
|
|
|
@test "(scheduler:report) selected raw vs computed vs global" {
|
|
run /bin/bash -c "dokku scheduler:set --global selected"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-selected\"'"
|
|
assert_success
|
|
assert_output ""
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-global-selected\"'"
|
|
assert_success
|
|
assert_output ""
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-computed-selected\"'"
|
|
assert_success
|
|
assert_output "docker-local"
|
|
|
|
run /bin/bash -c "dokku scheduler:set --global selected null"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-global-selected\"'"
|
|
assert_success
|
|
assert_output "null"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-computed-selected\"'"
|
|
assert_success
|
|
assert_output "null"
|
|
|
|
run /bin/bash -c "dokku scheduler:set $TEST_APP selected docker-local"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-selected\"'"
|
|
assert_success
|
|
assert_output "docker-local"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-global-selected\"'"
|
|
assert_success
|
|
assert_output "null"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-computed-selected\"'"
|
|
assert_success
|
|
assert_output "docker-local"
|
|
|
|
run /bin/bash -c "dokku scheduler:set $TEST_APP selected"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:set --global selected"
|
|
assert_success
|
|
}
|
|
|
|
@test "(scheduler:report) shell raw vs computed vs global" {
|
|
run /bin/bash -c "dokku scheduler:set --global shell"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-shell\"'"
|
|
assert_success
|
|
assert_output ""
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-global-shell\"'"
|
|
assert_success
|
|
assert_output ""
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-computed-shell\"'"
|
|
assert_success
|
|
assert_output ""
|
|
|
|
run /bin/bash -c "dokku scheduler:set --global shell sh"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-global-shell\"'"
|
|
assert_success
|
|
assert_output "sh"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-computed-shell\"'"
|
|
assert_success
|
|
assert_output "sh"
|
|
|
|
run /bin/bash -c "dokku scheduler:set $TEST_APP shell bash"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-shell\"'"
|
|
assert_success
|
|
assert_output "bash"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-global-shell\"'"
|
|
assert_success
|
|
assert_output "sh"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r '.\"scheduler-computed-shell\"'"
|
|
assert_success
|
|
assert_output "bash"
|
|
|
|
run /bin/bash -c "dokku scheduler:set $TEST_APP shell"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:set --global shell"
|
|
assert_success
|
|
}
|
|
|
|
@test "(scheduler:report) --global --format json" {
|
|
run /bin/bash -c "dokku scheduler:set --global selected"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report --global --format json | jq -e ."
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler:report --global --format json | jq -r '.\"scheduler-global-selected\"'"
|
|
assert_success
|
|
assert_output ""
|
|
|
|
run /bin/bash -c "dokku scheduler:report --global --format json | jq -r '.\"scheduler-computed-selected\"'"
|
|
assert_success
|
|
assert_output "docker-local"
|
|
|
|
run /bin/bash -c "dokku scheduler:report --global --format json | jq -r 'has(\"scheduler-selected\")'"
|
|
assert_success
|
|
assert_output "false"
|
|
}
|
|
|
|
@test "(scheduler:report) emits new stripped JSON keys alongside legacy" {
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r 'has(\"selected\") and has(\"scheduler-selected\")'"
|
|
assert_success
|
|
assert_output "true"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r 'has(\"global-selected\") and has(\"scheduler-global-selected\")'"
|
|
assert_success
|
|
assert_output "true"
|
|
|
|
run /bin/bash -c "dokku scheduler:report $TEST_APP --format json | jq -r 'has(\"computed-selected\") and has(\"scheduler-computed-selected\")'"
|
|
assert_success
|
|
assert_output "true"
|
|
|
|
run /bin/bash -c "dokku scheduler:report --global --format json | jq -r 'has(\"global-selected\") and has(\"scheduler-global-selected\")'"
|
|
assert_success
|
|
assert_output "true"
|
|
}
|