-init-
This commit is contained in:
59
tests/test_finish.sh
Executable file
59
tests/test_finish.sh
Executable file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ----- tiny test framework -----
|
||||
pass() { printf "✔ %s\n" "$1"; }
|
||||
fail() { printf "✘ %s\n" "$1"; exit 1; }
|
||||
|
||||
assert_ok() {
|
||||
if [[ $1 -ne 0 ]]; then fail "$2"; fi
|
||||
}
|
||||
|
||||
assert_nonempty() {
|
||||
if [[ -z "$1" ]]; then fail "$2"; fi
|
||||
}
|
||||
|
||||
assert_contains() {
|
||||
if [[ ! "$1" =~ $2 ]]; then fail "$3"; fi
|
||||
}
|
||||
# --------------------------------
|
||||
|
||||
echo "=== SETUP ==="
|
||||
bash ./docs/install.sh main
|
||||
source ~/.bashrc
|
||||
|
||||
finish config set provider lmstudio
|
||||
finish config set endpoint http://plato.lan:1234/v1/chat/completions
|
||||
finish config set model darkidol-llama-3.1-8b-instruct-1.3-uncensored_gguf:2
|
||||
|
||||
# -------------------------------- TESTS --------------------------------
|
||||
|
||||
# 1) which finish should return something
|
||||
out=$(which finish 2>&1) ; code=$?
|
||||
assert_ok $code "which finish should exit 0"
|
||||
assert_nonempty "$out" "which finish returned empty output"
|
||||
pass "which finish returns path"
|
||||
|
||||
# 2) finish output should contain 'finish.sh'
|
||||
out=$(finish 2>&1) ; code=$?
|
||||
assert_ok $code "finish should exit 0"
|
||||
assert_contains "$out" "finish\.sh" "finish output does not contain finish.sh"
|
||||
pass "finish outputs reference to finish.sh"
|
||||
|
||||
# 3) config should contain lmstudio
|
||||
out=$(finish config 2>&1) ; code=$?
|
||||
assert_ok $code "finish config should exit 0"
|
||||
assert_contains "$out" "lmstudio" "finish config missing lmstudio provider"
|
||||
pass "finish config contains lmstudio"
|
||||
|
||||
# 4) finish command should run
|
||||
out=$(finish command "ls # show largest files" 2>&1) ; code=$?
|
||||
assert_ok $code "finish command did not exit 0"
|
||||
assert_nonempty "$out" "finish command returned empty output"
|
||||
pass "finish command executed and returned output"
|
||||
|
||||
# ------------------------------- CLEANUP --------------------------------
|
||||
echo "=== CLEANUP ==="
|
||||
finish remove -y || true
|
||||
|
||||
echo "All tests passed."
|
||||
Reference in New Issue
Block a user