tests: тестовые ресурсы с префиксом test-/t-, ns fission-test-*, guard в cleanup
This commit is contained in:
@@ -9,7 +9,7 @@ source "${ROOT_DIR}/lib.sh"
|
||||
|
||||
NS_CLEANUP_SCRIPT="${ROOT_DIR}/cleanup_test_namespaces.sh"
|
||||
RUN_ID=$(mk_run_id)
|
||||
SUB="crud-${RUN_ID}@test.local"
|
||||
SUB="test-crud-${RUN_ID}@test.local"
|
||||
|
||||
cleanup() {
|
||||
if [ -x "$NS_CLEANUP_SCRIPT" ]; then
|
||||
@@ -31,14 +31,14 @@ echo ""
|
||||
echo ">>> CREATE: базовый nodejs → 201"
|
||||
R=$(curl -s -w "\n%{http_code}" -X POST "${BASE}/functions" \
|
||||
-H "X-Auth-Token: ${SUB}" -H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"crud-fn-${RUN_ID}\",\"language\":\"nodejs\",\"code\":$(printf '%s' "$JS_CODE" | json_escape)}")
|
||||
-d "{\"name\":\"t-crud-fn-${RUN_ID}\",\"language\":\"nodejs\",\"code\":$(printf '%s' "$JS_CODE" | json_escape)}")
|
||||
CODE=$(echo "$R" | tail -1)
|
||||
BODY=$(echo "$R" | sed '$d')
|
||||
check_http "$CODE" "201" "CREATE nodejs → 201"
|
||||
FN_NAME=$(json_field "$BODY" name)
|
||||
FN_ROUTE=$(json_field "$BODY" route)
|
||||
FN_PKG=$(json_field "$BODY" package)
|
||||
[ "$FN_NAME" = "crud-fn-${RUN_ID}" ] && pass "CREATE: name в ответе" || fail "CREATE: name='$FN_NAME'"
|
||||
[ "$FN_NAME" = "t-crud-fn-${RUN_ID}" ] && pass "CREATE: name в ответе" || fail "CREATE: name='$FN_NAME'"
|
||||
printf '%s' "$FN_ROUTE" | grep -q '/' && pass "CREATE: route непустой" || fail "CREATE: route='$FN_ROUTE'"
|
||||
[ -n "$FN_PKG" ] && pass "CREATE: package непустой" || fail "CREATE: package пустой"
|
||||
|
||||
@@ -46,7 +46,7 @@ echo ""
|
||||
echo ">>> CREATE: дубликат → 409"
|
||||
R=$(curl -s -w "\n%{http_code}" -X POST "${BASE}/functions" \
|
||||
-H "X-Auth-Token: ${SUB}" -H "Content-Type: application/json" \
|
||||
-d "{\"name\":\"crud-fn-${RUN_ID}\",\"language\":\"nodejs\",\"code\":$(printf '%s' "$JS_CODE" | json_escape)}")
|
||||
-d "{\"name\":\"t-crud-fn-${RUN_ID}\",\"language\":\"nodejs\",\"code\":$(printf '%s' "$JS_CODE" | json_escape)}")
|
||||
check_http "$(echo "$R" | tail -1)" "409" "CREATE дубликат → 409"
|
||||
|
||||
echo ""
|
||||
@@ -158,13 +158,13 @@ COUNT=$(json_len "$BODY")
|
||||
|
||||
echo ""
|
||||
echo ">>> GET: /functions/{name} → 200"
|
||||
R=$(curl -s -w "\n%{http_code}" "${BASE}/functions/crud-fn-${RUN_ID}" \
|
||||
R=$(curl -s -w "\n%{http_code}" "${BASE}/functions/t-crud-fn-${RUN_ID}" \
|
||||
-H "X-Auth-Token: ${SUB}")
|
||||
CODE=$(echo "$R" | tail -1)
|
||||
BODY=$(echo "$R" | sed '$d')
|
||||
check_http "$CODE" "200" "GET /functions/crud-fn-${RUN_ID} → 200"
|
||||
check_http "$CODE" "200" "GET /functions/t-crud-fn-${RUN_ID} → 200"
|
||||
GOT_NAME=$(json_field "$BODY" name)
|
||||
[ "$GOT_NAME" = "crud-fn-${RUN_ID}" ] && pass "GET: name совпадает" || fail "GET: name='$GOT_NAME'"
|
||||
[ "$GOT_NAME" = "t-crud-fn-${RUN_ID}" ] && pass "GET: name совпадает" || fail "GET: name='$GOT_NAME'"
|
||||
GOT_ENV=$(json_field "$BODY" environment)
|
||||
[ -n "$GOT_ENV" ] && pass "GET: environment непустой ($GOT_ENV)" || fail "GET: environment пустой"
|
||||
|
||||
@@ -178,7 +178,7 @@ check_http "$(echo "$R" | tail -1)" "404" "GET несуществующая →
|
||||
|
||||
echo ""
|
||||
echo ">>> DELETE: /functions/{name} → 200"
|
||||
R=$(curl -s -w "\n%{http_code}" -X DELETE "${BASE}/functions/crud-fn-${RUN_ID}" \
|
||||
R=$(curl -s -w "\n%{http_code}" -X DELETE "${BASE}/functions/t-crud-fn-${RUN_ID}" \
|
||||
-H "X-Auth-Token: ${SUB}")
|
||||
CODE=$(echo "$R" | tail -1)
|
||||
BODY=$(echo "$R" | sed '$d')
|
||||
@@ -188,13 +188,13 @@ DELETED=$(json_field "$BODY" deleted)
|
||||
|
||||
echo ""
|
||||
echo ">>> DELETE: повторное удаление → 404"
|
||||
R=$(curl -s -w "\n%{http_code}" -X DELETE "${BASE}/functions/crud-fn-${RUN_ID}" \
|
||||
R=$(curl -s -w "\n%{http_code}" -X DELETE "${BASE}/functions/t-crud-fn-${RUN_ID}" \
|
||||
-H "X-Auth-Token: ${SUB}")
|
||||
check_http "$(echo "$R" | tail -1)" "404" "DELETE повторное → 404"
|
||||
|
||||
echo ""
|
||||
echo ">>> GET: после DELETE → 404"
|
||||
R=$(curl -s -w "\n%{http_code}" "${BASE}/functions/crud-fn-${RUN_ID}" \
|
||||
R=$(curl -s -w "\n%{http_code}" "${BASE}/functions/t-crud-fn-${RUN_ID}" \
|
||||
-H "X-Auth-Token: ${SUB}")
|
||||
check_http "$(echo "$R" | tail -1)" "404" "GET после DELETE → 404"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user