Files
dokku/tests/unit/haproxy-vhosts.bats
Jose Diaz-Gonzalez 5faabea3d4 feat: port vhost proxy :report subcommands to golang
The bash :report implementations for the caddy, haproxy, openresty, and traefik proxy plugins are replaced with a compiled golang binary that collects report keys in parallel and marshals json directly. The traefik dns-provider values keep their masking behaviour, remaining hidden in the default stdout report while surfacing for --format json or an explicit flag query. These four plugins previously had no unit tests, so a bats suite covering the report matrix is added for each.
2026-07-07 06:29:01 -04:00

77 lines
2.0 KiB
Bash

#!/usr/bin/env bats
load test_helper
setup() {
create_app
}
teardown() {
destroy_app
dokku haproxy:set --global log-level >/dev/null 2>&1 || true
dokku haproxy:set --global refresh-conf >/dev/null 2>&1 || true
}
@test "(haproxy:report) info-flag works before deploy" {
run /bin/bash -c "dokku haproxy:set --global refresh-conf"
assert_success
run /bin/bash -c "dokku haproxy:report $TEST_APP --haproxy-computed-refresh-conf"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "10"
run /bin/bash -c "dokku haproxy:report $TEST_APP --haproxy-invalid-flag"
echo "output: $output"
echo "status: $status"
assert_failure
assert_output_contains "Invalid flag passed"
}
@test "(haproxy:report) --format json" {
run /bin/bash -c "dokku haproxy:set --global log-level"
assert_success
run /bin/bash -c "dokku haproxy:report --global --format json | jq -e ."
echo "output: $output"
echo "status: $status"
assert_success
run /bin/bash -c "dokku haproxy:report --global --format json | jq -r '.\"computed-log-level\"'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "ERROR"
run /bin/bash -c "dokku haproxy:report --global"
echo "output: $output"
echo "status: $status"
assert_success
assert_output_contains "global haproxy information"
}
@test "(haproxy:report) refresh-conf global computed" {
run /bin/bash -c "dokku haproxy:set --global refresh-conf"
assert_success
run /bin/bash -c "dokku haproxy:report --global --haproxy-global-refresh-conf"
assert_success
assert_output ""
run /bin/bash -c "dokku haproxy:report --global --haproxy-computed-refresh-conf"
assert_success
assert_output "10"
run /bin/bash -c "dokku haproxy:set --global refresh-conf 30"
assert_success
run /bin/bash -c "dokku haproxy:report --global --haproxy-global-refresh-conf"
assert_success
assert_output "30"
run /bin/bash -c "dokku haproxy:report --global --haproxy-computed-refresh-conf"
assert_success
assert_output "30"
}