test(entrypoint): 補上 prompt 邊界與映像檔 smoke 測試
This commit is contained in:
@@ -16,6 +16,7 @@ make_fake_codex() {
|
||||
|
||||
cat > "$dir/codex" <<SH
|
||||
#!/bin/sh
|
||||
printf '%s\n' "\$*" > "\${CODEX_FAKE_ARGS:-/dev/null}"
|
||||
echo "$message"
|
||||
exit $exit_code
|
||||
SH
|
||||
@@ -118,6 +119,30 @@ test_success_output() {
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
test_empty_prompt() {
|
||||
local tmpdir
|
||||
tmpdir="$(mktemp -d)"
|
||||
make_fake_codex "$tmpdir" 0 "codex ok"
|
||||
|
||||
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT=""
|
||||
|
||||
grep -q "codex ok" "$tmpdir/github-output" || die "empty prompt output"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
test_prompt_with_shell_characters() {
|
||||
local tmpdir
|
||||
local prompt
|
||||
tmpdir="$(mktemp -d)"
|
||||
prompt='hello; rm -rf / $(echo bad) "quoted"'
|
||||
make_fake_codex "$tmpdir" 0 "codex ok"
|
||||
|
||||
run_entrypoint "$tmpdir" OAUTH="$(encoded_json '{}')" MODEL="gpt-test" PROMPT="$prompt" CODEX_FAKE_ARGS="$tmpdir/codex-args"
|
||||
|
||||
grep -qF "$prompt" "$tmpdir/codex-args" || die "prompt was not passed as one argument"
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
test_failure_output() {
|
||||
local tmpdir
|
||||
tmpdir="$(mktemp -d)"
|
||||
@@ -140,6 +165,8 @@ test_missing_model
|
||||
test_invalid_base64
|
||||
test_non_object_json
|
||||
test_success_output
|
||||
test_empty_prompt
|
||||
test_prompt_with_shell_characters
|
||||
test_failure_output
|
||||
|
||||
echo "entrypoint tests passed"
|
||||
|
||||
Reference in New Issue
Block a user