Close the wiring blank gap and label uninstall removals.

Skip wait newlines when an API key is already present, and say
config/media were removed instead of listing them like a live status.
This commit is contained in:
soulis-1256 2026-08-19 00:05:43 +03:00
parent f5e7d18edf
commit 54f3aaa7cd
No known key found for this signature in database
9 changed files with 54 additions and 10 deletions

View file

@ -490,19 +490,19 @@ uninstall_app() {
log_success "${APP_DISPLAY_NAME} uninstalled."
if [ "$removed_config" = true ]; then
echo " Config: $INSTALL_DIR"
echo " Config removed: $INSTALL_DIR"
else
echo " Config kept: $INSTALL_DIR"
fi
if [ "$removed_media" = true ]; then
echo " Media: $MEDIA_DIRECTORY"
echo " Media removed: $MEDIA_DIRECTORY"
else
echo " Media kept: $MEDIA_DIRECTORY"
fi
local p
if [ "${#extra_removed[@]}" -gt 0 ]; then
for p in "${extra_removed[@]}"; do
echo " Leftover: $p"
echo " Leftover removed: $p"
done
fi
if [ "${#extra_kept[@]}" -gt 0 ]; then

View file

@ -113,7 +113,6 @@ source "$_lib_dir/bazarr.sh"
echo
_cfg_log_info "Wiring ${APP_DISPLAY_NAME} services..."
echo
# API keys from config.xml (services write these on first start)
RADARR_API_KEY=""

View file

@ -38,7 +38,7 @@ read_api_key() {
local key
key=$(sed -n 's/.*<ApiKey>\(.*\)<\/ApiKey>.*/\1/p' "$config_file" 2>/dev/null | head -1)
if [ -n "$key" ]; then
echo >&2
[ "$wait_time" -gt 0 ] && echo >&2
echo "$key"
return 0
fi
@ -134,7 +134,7 @@ wait_for_api() {
while [ $wait_time -lt $max_wait ]; do
if _api_ready "$port" "$apikey" "$api_path"; then
echo >&2
[ "$wait_time" -gt 0 ] && echo >&2
return 0
fi
wait_inline "Waiting for $name API" "$wait_time"

View file

@ -66,7 +66,7 @@ read_bazarr_api_key() {
if cfg=$(_bazarr_config_file 2>/dev/null); then
key=$(_bazarr_extract_apikey "$cfg")
if [ -n "$key" ] && [ "$key" != "null" ]; then
echo >&2
[ "$wait_time" -gt 0 ] && echo >&2
echo "$key"
return 0
fi
@ -90,7 +90,7 @@ wait_for_bazarr() {
code=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 \
"http://${API_HOST}:${BAZARR_PORT}/api/system/status?apikey=${apikey}" 2>/dev/null || echo "000")
if [ "$code" = "200" ]; then
echo >&2
[ "$wait_time" -gt 0 ] && echo >&2
return 0
fi
wait_inline "Waiting for Bazarr API" "$wait_time"

View file

@ -31,9 +31,8 @@ ui_set_mode() {
esac
}
# Two-line intro: setup copy, then edit copy.
# One blank line, then setup or edit copy.
ui_intro() {
echo
echo
if ui_is_edit; then
log_info "$2"

View file

@ -36,6 +36,7 @@ run_scripts() {
run_unit() {
echo "Running unit tests..."
for f in \
"$SCRIPT_DIR/unit/test_api.sh" \
"$SCRIPT_DIR/unit/test_arr_quality.sh" \
"$SCRIPT_DIR/unit/test_compose.sh" \
"$SCRIPT_DIR/unit/test_config_edit.sh" \

30
tests/unit/test_api.sh Normal file
View file

@ -0,0 +1,30 @@
#!/bin/bash
# Unit tests for lib/api.sh wait/key helpers (no live stack).
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/../helpers.sh"
# shellcheck disable=SC1091
source "$REPO_ROOT/lib/core.sh"
stub_log_error_no_exit
log_step() { :; }
log_step_fail() { echo "fail: $1" >&2; }
# shellcheck disable=SC1091
source "$REPO_ROOT/lib/api.sh"
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT
INSTALL_DIR="$tmp"
API_HOST=127.0.0.1
mkdir -p "$tmp/config/radarr"
printf '<Config><ApiKey>abc123</ApiKey></Config>\n' >"$tmp/config/radarr/config.xml"
test_suite "read_api_key already present"
err=$(mktemp)
key=$(read_api_key radarr 2>"$err")
assert_eq "abc123" "$key" "returns key from config.xml"
assert_eq "" "$(cat "$err")" "no blank wait line when the key is already there"
test_summary

View file

@ -105,6 +105,12 @@ assert_not_contains "$un" "Stopping all services" "no step-by-step stop line"
assert_not_contains "$un" "Removing config at" "no Removing-config play-by-play"
assert_not_contains "$un" "Docker images were left" "no leftover-images lecture"
assert_contains "$un" "uninstalled." "one done line"
assert_contains "$un" "Config removed:" "removed config is labeled removed"
assert_contains "$un" "Media removed:" "removed media is labeled removed"
assert_contains "$un" "Config kept:" "kept config is labeled kept"
assert_contains "$un" "Media kept:" "kept media is labeled kept"
assert_not_contains "$un" 'echo " Config: $INSTALL_DIR"' "does not print a status-style Config path"
assert_not_contains "$un" 'echo " Media: $MEDIA_DIRECTORY"' "does not print a status-style Media path"
test_suite "config show survives missing VPN_TYPE/TZ"
cli="$REPO_ROOT/bin/cli.sh"

View file

@ -26,6 +26,15 @@ assert_eq "setup" "$(ui_mode)" "back to setup"
ui_set_mode bogus
assert_eq "setup" "$(ui_mode)" "unknown mode falls back to setup"
test_suite "ui_intro spacing"
ui_set_mode setup
intro=$(ui_intro "Pick indexers." "Change indexers.")
assert_eq $'\nPick indexers.' "$intro" "one blank line before setup copy"
ui_set_mode edit
intro=$(ui_intro "Pick indexers." "Change indexers.")
assert_eq $'\nChange indexers.' "$intro" "one blank line before edit copy"
ui_set_mode setup
test_suite "ui_intro / ui_picker_done copy"
ui_set_mode setup
FZF_SELECT_STATUS=cancelled