#!/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