test(entrypoint): 驗證 Node.js 入口錯誤輸出
This commit is contained in:
@@ -58,6 +58,8 @@ test_missing_oauth() {
|
|||||||
|
|
||||||
assert_status "$status" 1
|
assert_status "$status" 1
|
||||||
grep -q "OAUTH is required" "$tmpdir/stderr" || die "missing OAUTH error"
|
grep -q "OAUTH is required" "$tmpdir/stderr" || die "missing OAUTH error"
|
||||||
|
grep -q "status=failed" "$tmpdir/github-output" || die "missing OAUTH failed status output"
|
||||||
|
grep -q "OAUTH is required" "$tmpdir/github-output" || die "missing OAUTH output"
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +75,8 @@ test_missing_model() {
|
|||||||
|
|
||||||
assert_status "$status" 1
|
assert_status "$status" 1
|
||||||
grep -q "MODEL is required" "$tmpdir/stderr" || die "missing MODEL error"
|
grep -q "MODEL is required" "$tmpdir/stderr" || die "missing MODEL error"
|
||||||
|
grep -q "status=failed" "$tmpdir/github-output" || die "missing MODEL failed status output"
|
||||||
|
grep -q "MODEL is required" "$tmpdir/github-output" || die "missing MODEL output"
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +92,8 @@ test_invalid_base64() {
|
|||||||
|
|
||||||
assert_status "$status" 1
|
assert_status "$status" 1
|
||||||
grep -q "valid base64" "$tmpdir/stderr" || die "invalid base64 error"
|
grep -q "valid base64" "$tmpdir/stderr" || die "invalid base64 error"
|
||||||
|
grep -q "status=failed" "$tmpdir/github-output" || die "invalid base64 failed status output"
|
||||||
|
grep -q "valid base64" "$tmpdir/github-output" || die "invalid base64 output"
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,6 +109,8 @@ test_non_object_json() {
|
|||||||
|
|
||||||
assert_status "$status" 1
|
assert_status "$status" 1
|
||||||
grep -q "JSON object" "$tmpdir/stderr" || die "non-object JSON error"
|
grep -q "JSON object" "$tmpdir/stderr" || die "non-object JSON error"
|
||||||
|
grep -q "status=failed" "$tmpdir/github-output" || die "non-object JSON failed status output"
|
||||||
|
grep -q "JSON object" "$tmpdir/github-output" || die "non-object JSON output"
|
||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +168,28 @@ test_failure_output() {
|
|||||||
rm -rf "$tmpdir"
|
rm -rf "$tmpdir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_missing_codex_command_output() {
|
||||||
|
local tmpdir
|
||||||
|
local bindir
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
bindir="$tmpdir/bin"
|
||||||
|
mkdir -p "$bindir"
|
||||||
|
ln -s "$(command -v bash)" "$bindir/bash"
|
||||||
|
ln -s "$(command -v dirname)" "$bindir/dirname"
|
||||||
|
ln -s "$(command -v node)" "$bindir/node"
|
||||||
|
|
||||||
|
set +e
|
||||||
|
run_entrypoint "$tmpdir" PATH="$bindir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="hello"
|
||||||
|
local status="$?"
|
||||||
|
set -e
|
||||||
|
|
||||||
|
assert_status "$status" 1
|
||||||
|
grep -q "status=failed" "$tmpdir/github-output" || die "missing codex command failed status output"
|
||||||
|
grep -q "spawn codex ENOENT" "$tmpdir/github-output" || die "missing codex command error output"
|
||||||
|
[[ ! -e "$tmpdir/codex-home/auth.json" ]] || die "auth.json was not cleaned up after missing codex"
|
||||||
|
rm -rf "$tmpdir"
|
||||||
|
}
|
||||||
|
|
||||||
test_missing_oauth
|
test_missing_oauth
|
||||||
test_missing_model
|
test_missing_model
|
||||||
test_invalid_base64
|
test_invalid_base64
|
||||||
@@ -168,5 +198,6 @@ test_success_output
|
|||||||
test_empty_prompt
|
test_empty_prompt
|
||||||
test_prompt_with_shell_characters
|
test_prompt_with_shell_characters
|
||||||
test_failure_output
|
test_failure_output
|
||||||
|
test_missing_codex_command_output
|
||||||
|
|
||||||
echo "entrypoint tests passed"
|
echo "entrypoint tests passed"
|
||||||
|
|||||||
Reference in New Issue
Block a user