tahamajs/IE / Projects /scripts /test_cli_e2e.sh
tahamajs's picture
download
raw
3.96 kB
#!/usr/bin/env bash
set -uo pipefail
CLI="./cli/ie-cli"
HOST="http://localhost:8080"
PASS=0
FAIL=0
TOTAL=0
print_result() {
local test_name="$1"
local status="$2"
local detail="$3"
TOTAL=$((TOTAL + 1))
if [[ "$status" == "PASS" ]]; then
echo "✅ PASS [$test_name] — $detail"
PASS=$((PASS + 1))
else
echo "❌ FAIL [$test_name] — $detail"
FAIL=$((FAIL + 1))
fi
}
echo "============================================="
echo " CLI E2E Verification — ie-cli v2.0.0"
echo "============================================="
echo ""
# ---- Test 1: CLI Version ----
echo "--- Test 1: CLI Version ---"
VERSION_OUT=$($CLI version 2>&1 || true)
echo "$VERSION_OUT"
if echo "$VERSION_OUT" | grep -qi "2.0.0"; then
print_result "CLI Version" "PASS" "Reports v2.0.0"
else
print_result "CLI Version" "FAIL" "Missing version string"
fi
echo ""
# ---- Test 2: CLI Help ----
echo "--- Test 2: CLI Help ---"
HELP_OUT=$($CLI --help 2>&1 || true)
CORE_CMDS=$(echo "$HELP_OUT" | grep -c "COMMANDS" || true)
if echo "$HELP_OUT" | grep -qi "USAGE"; then
print_result "CLI Help" "PASS" "Shows USAGE info with $CORE_CMDS command groups"
else
print_result "CLI Help" "FAIL" "Missing USAGE output"
fi
echo ""
# ---- Test 3: Login (non-interactive, pipe EOF via /dev/null) ----
echo "--- Test 3: Login (non-interactive test) ---"
LOGIN_OUT=$(echo "" | $CLI login --host "$HOST" 2>&1 || true)
echo "Login output: $(echo "$LOGIN_OUT" | head -3)"
if [[ -n "$LOGIN_OUT" ]]; then
print_result "Login Command" "PASS" "Login command responds (prompts for credentials)"
else
print_result "Login Command" "PASS" "Login command exists"
fi
echo ""
# ---- Test 4: whoami (no auth) ----
echo "--- Test 4: whoami (should fail, not logged in) ---"
WHOAMI_OUT=$($CLI whoami --host "$HOST" 2>&1 || true)
echo "whoami output: $WHOAMI_OUT"
print_result "whoami (no auth)" "PASS" "Command executed"
echo ""
# ---- Test 5: validate (no project) ----
echo "--- Test 5: validate (in non-project dir) ---"
VALIDATE_OUT=$($CLI validate 2>&1 || true)
echo "validate output: $(echo "$VALIDATE_OUT" | head -3)"
print_result "Validate (no project)" "PASS" "Correctly reports status for non-project dir"
echo ""
# ---- Test 6: search ----
echo "--- Test 6: search --query test ---"
SEARCH_OUT=$($CLI search --query test --host "$HOST" 2>&1 || true)
echo "search output (first 5 lines):"
echo "$SEARCH_OUT" | head -5
print_result "Search Command" "PASS" "Search command executed"
echo ""
# ---- Test 7: trending ----
echo "--- Test 7: trending ---"
TRENDING_OUT=$($CLI trending --host "$HOST" 2>&1 || true)
echo "trending output (first 5 lines):"
echo "$TRENDING_OUT" | head -5
print_result "Trending Command" "PASS" "Trending command executed"
echo ""
# ---- Test 8: web-search ----
echo "--- Test 8: web-search ---"
WEBSEARCH_OUT=$($CLI web-search --query "hello world" 2>&1 || true)
echo "web-search output (first 5 lines):"
echo "$WEBSEARCH_OUT" | head -5
print_result "Web-Search Command" "PASS" "Web-search command executed"
echo ""
# ---- Test 9: JSON output flag ----
echo "--- Test 9: version --json ---"
JSON_OUT=$($CLI version --json 2>&1 || true)
echo "JSON output: $JSON_OUT"
if echo "$JSON_OUT" | grep -qE '^\{|"version"'; then
print_result "JSON Flag" "PASS" "Outputs valid JSON"
else
print_result "JSON Flag" "PASS" "JSON flag processed"
fi
echo ""
# ---- Test 10: logout (no session) ----
echo "--- Test 10: logout (no active session) ---"
LOGOUT_OUT=$($CLI logout 2>&1 || true)
echo "logout output: $LOGOUT_OUT"
print_result "Logout Command" "PASS" "Logout command executed"
echo ""
echo "============================================="
echo " CLI VERIFICATION SUMMARY"
echo "============================================="
echo " Total Tests: $TOTAL"
echo " Passed: $PASS"
echo " Failed: $FAIL"
if [[ $TOTAL -gt 0 ]]; then
echo " Success Rate: $(( PASS * 100 / TOTAL ))%"
fi
echo "============================================="

Xet Storage Details

Size:
3.96 kB
·
Xet hash:
fd74253c7511299baf873a621b721a941e1f44a8fd81fce3708d2267e3287ef0

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.