tests: тестовые ресурсы с префиксом test-/t-, ns fission-test-*, guard в cleanup

This commit is contained in:
“Naeel”
2026-05-03 17:59:12 +04:00
parent 47759b5231
commit cf475d0d2d
10 changed files with 102 additions and 73 deletions
+3 -3
View File
@@ -10,7 +10,7 @@ source "${ROOT_DIR}/lib.sh"
NS_CLEANUP_SCRIPT="${ROOT_DIR}/cleanup_test_namespaces.sh"
RUN_ID=$(mk_run_id)
SUB="ttl-${RUN_ID}@test.local"
SUB="test-ttl-${RUN_ID}@test.local"
cleanup() {
if [ -x "$NS_CLEANUP_SCRIPT" ]; then
@@ -32,7 +32,7 @@ echo ""
echo ">>> CREATE без TTL → expires_at отсутствует"
R=$(curl -s -X POST "${BASE}/functions" \
-H "X-Auth-Token: ${SUB}" -H "Content-Type: application/json" \
-d "{\"name\":\"nttl-fn\",\"language\":\"nodejs\",\"code\":$(printf '%s' "$JS_CODE" | json_escape)}")
-d "{\"name\":\"t-nttl-fn\",\"language\":\"nodejs\",\"code\":$(printf '%s' "$JS_CODE" | json_escape)}")
CODE_HTTP=$(printf '%s' "$R" | python3 -c "import sys; lines=sys.stdin.read().split('\n'); print(lines[-1] if lines else '')" 2>/dev/null || echo "?")
EXPIRES=$(json_field "$R" expires_at)
[ -z "$EXPIRES" ] && pass "CREATE без TTL: expires_at отсутствует" || fail "CREATE без TTL: expires_at='$EXPIRES'"
@@ -77,7 +77,7 @@ for badttl in "99z" "abc" "0d" "-1h" ""; do
if [ -z "$badttl" ]; then continue; fi
R=$(curl -s -w "\n%{http_code}" -X POST "${BASE}/functions" \
-H "X-Auth-Token: ${SUB}" -H "Content-Type: application/json" \
-d "{\"name\":\"badttl-fn\",\"language\":\"nodejs\",\"code\":\"x\",\"ttl\":\"${badttl}\"}")
-d "{\"name\":\"t-badttl-fn\",\"language\":\"nodejs\",\"code\":\"x\",\"ttl\":\"${badttl}\"}")
CODE=$(echo "$R" | tail -1)
[ "$CODE" = "400" ] && pass "TTL='$badttl' → 400" || fail "TTL='$badttl' → got $CODE"
done