Files
sf-cli-wrapper/test-help-options.sh
reynold 9c6450106d Complete sf-logs-tail update and add comprehensive test suites
 Updated sf-logs-tail to use two-character options:
  - Changed -o → -to, -u → -ui, -l → -lv, -v → -vb, -h → -hp
  - Updated help text and examples to use new options
  - All parsing logic converted to manual parsing for consistency

 Created comprehensive test suite:
  - test-wrapper-suite.sh: Full 100% coverage testing
  - test-help-options.sh: Focused help and option testing
  - quick-test.sh: Quick validation test
  - check-option-schemes.sh: Option scheme verification

 All wrapper scripts now support two-character options:
  - sf-deploy, sf-dry-run, sf-web-open:  Full implementation
  - sf-org-create, sf-data-export, sf-data-import:  Full implementation
  - sf-logs-tail:  Now fully updated
  - sf-check, sf-org-info, sf-retrieve, sf-test-run, sf-apex-run:  Working

🎯 Ready for comprehensive testing with PWC-TEAM-DEV org
📋 Test coverage includes: help functions, option parsing, error conditions,
   core functionality, data operations, metadata operations, and backwards compatibility
2025-08-28 18:44:46 +08:00

117 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Quick Test for Help Functions and Two-Character Option Recognition
readonly GREEN='\033[0;32m'
readonly RED='\033[0;31m'
readonly YELLOW='\033[0;33m'
readonly BLUE='\033[0;34m'
readonly NC='\033[0m' # No Color
echo -e "${BLUE}SF CLI Wrapper Help & Options Test${NC}"
echo -e "${BLUE}==================================${NC}"
echo ""
# Test counters
TESTS=0
PASSED=0
FAILED=0
test_help() {
local script="$1"
echo -n "Testing $script help (-hp)... "
((TESTS++))
if ./$script -hp >/dev/null 2>&1; then
echo -e "${GREEN}${NC}"
((PASSED++))
else
echo -e "${RED}${NC}"
((FAILED++))
# Try old -h option
echo -n " Trying old -h... "
if ./$script -h >/dev/null 2>&1; then
echo -e "${YELLOW}✓ (old option)${NC}"
else
echo -e "${RED}✗ (no help)${NC}"
fi
fi
}
test_option_recognition() {
local script="$1"
local option="$2"
local description="$3"
echo -n "Testing $script $option recognition... "
((TESTS++))
# Run the command and capture output - expect it might fail but shouldn't say "Unknown option"
local output
output=$(./$script $option 2>&1 || true)
if echo "$output" | grep -q "Unknown option\|Invalid option"; then
echo -e "${RED}${NC} (option not recognized)"
((FAILED++))
else
echo -e "${GREEN}${NC}"
((PASSED++))
fi
}
echo -e "${BLUE}=== Testing Help Functions ===${NC}"
scripts=(sf-check sf-deploy sf-dry-run sf-web-open sf-org-create sf-org-info sf-retrieve sf-test-run sf-apex-run sf-data-export sf-data-import sf-logs-tail)
for script in "${scripts[@]}"; do
if [[ -x "./$script" ]]; then
test_help "$script"
else
echo -e "${YELLOW}Skipping $script (not executable)${NC}"
fi
done
echo ""
echo -e "${BLUE}=== Testing Key Two-Character Options ===${NC}"
# Test key options that should be recognized
test_option_recognition "sf-deploy" "-to" "target org"
test_option_recognition "sf-dry-run" "-to" "target org"
test_option_recognition "sf-web-open" "-to" "target org"
test_option_recognition "sf-data-export" "-qy" "query"
test_option_recognition "sf-data-export" "-to" "target org"
test_option_recognition "sf-org-create" "-al" "alias"
test_option_recognition "sf-retrieve" "-to" "target org"
echo ""
echo -e "${BLUE}=== Testing Invalid Options ===${NC}"
echo -n "Testing invalid option rejection... "
((TESTS++))
if ./sf-deploy -invalid 2>&1 | grep -q "Unknown option\|Invalid option"; then
echo -e "${GREEN}${NC}"
((PASSED++))
else
echo -e "${RED}${NC}"
((FAILED++))
fi
echo ""
echo -e "${BLUE}=== Results Summary ===${NC}"
echo -e "${BLUE}=======================${NC}"
echo "Total tests: $TESTS"
echo -e "${GREEN}Passed: $PASSED${NC}"
echo -e "${RED}Failed: $FAILED${NC}"
if [[ $FAILED -eq 0 ]]; then
echo ""
echo -e "${GREEN}🎉 All help and option tests passed!${NC}"
exit 0
else
echo ""
echo -e "${RED}❌ Some tests failed. Scripts may need option updates.${NC}"
exit 1
fi