處理 AI review findings 並改寫 Node.js entrypoint #1
+12
-12
@@ -4,7 +4,7 @@ set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
fail() {
|
||||
die() {
|
||||
|
Ghost marked this conversation as resolved
Outdated
|
||||
echo "FAIL: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
@@ -42,7 +42,7 @@ assert_status() {
|
||||
local actual="$1"
|
||||
local expected="$2"
|
||||
|
||||
[[ "$actual" -eq "$expected" ]] || fail "expected status $expected, got $actual"
|
||||
[[ "$actual" -eq "$expected" ]] || die "expected status $expected, got $actual"
|
||||
}
|
||||
|
||||
test_missing_oauth() {
|
||||
@@ -56,7 +56,7 @@ test_missing_oauth() {
|
||||
set -e
|
||||
|
||||
assert_status "$status" 1
|
||||
grep -q "OAUTH is required" "$tmpdir/stderr" || fail "missing OAUTH error"
|
||||
grep -q "OAUTH is required" "$tmpdir/stderr" || die "missing OAUTH error"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ test_missing_model() {
|
||||
set -e
|
||||
|
||||
assert_status "$status" 1
|
||||
grep -q "MODEL is required" "$tmpdir/stderr" || fail "missing MODEL error"
|
||||
grep -q "MODEL is required" "$tmpdir/stderr" || die "missing MODEL error"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ test_invalid_base64() {
|
||||
set -e
|
||||
|
||||
assert_status "$status" 1
|
||||
grep -q "valid base64" "$tmpdir/stderr" || fail "invalid base64 error"
|
||||
grep -q "valid base64" "$tmpdir/stderr" || die "invalid base64 error"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ test_non_object_json() {
|
||||
set -e
|
||||
|
||||
assert_status "$status" 1
|
||||
grep -q "JSON object" "$tmpdir/stderr" || fail "non-object JSON error"
|
||||
grep -q "JSON object" "$tmpdir/stderr" || die "non-object JSON error"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
@@ -112,9 +112,9 @@ test_success_output() {
|
||||
|
||||
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="hello"
|
||||
|
||||
grep -q "status=completed" "$tmpdir/github-output" || fail "completed status output"
|
||||
grep -q "codex ok" "$tmpdir/github-output" || fail "codex output"
|
||||
[[ ! -e "$tmpdir/codex-home/auth.json" ]] || fail "auth.json was not cleaned up"
|
||||
grep -q "status=completed" "$tmpdir/github-output" || die "completed status output"
|
||||
grep -q "codex ok" "$tmpdir/github-output" || die "codex output"
|
||||
[[ ! -e "$tmpdir/codex-home/auth.json" ]] || die "auth.json was not cleaned up"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
@@ -129,9 +129,9 @@ test_failure_output() {
|
||||
set -e
|
||||
|
||||
assert_status "$status" 7
|
||||
grep -q "status=failed" "$tmpdir/github-output" || fail "failed status output"
|
||||
grep -q "codex failed" "$tmpdir/github-output" || fail "failed codex output"
|
||||
[[ ! -e "$tmpdir/codex-home/auth.json" ]] || fail "auth.json was not cleaned up after failure"
|
||||
grep -q "status=failed" "$tmpdir/github-output" || die "failed status output"
|
||||
grep -q "codex failed" "$tmpdir/github-output" || die "failed codex output"
|
||||
[[ ! -e "$tmpdir/codex-home/auth.json" ]] || die "auth.json was not cleaned up after failure"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user
嚴重等級:🔵 建議
審查員:Bard
問題:專案在
entrypoint.sh中使用die函數處理致命錯誤,但測試腳本中卻定義了名稱不同的fail函數,這使得專案內的錯誤處理語彙不夠一致,略顯突兀。建議:建議將
tests/entrypoint_test.sh中的fail函數更名為die,使錯誤處理的語彙在專案各處保持一致,讓樂章的節奏更為統一。