#!/bin/bash
# test-env.sh
# Author: Matthew Raymer
# Description: Test script to verify environment variable handling
# This script tests the environment variable setup functions.

# Exit on any error
set -e

# Source common utilities
source "$(dirname "$0")/common.sh"

# Parse command line arguments
parse_args "$@"

# Print test header
print_header "Environment Variable Test"
log_info "Testing environment variable handling at $(date)"

# Test 1: Capacitor environment
log_info "Test 1: Setting up Capacitor environment..."
setup_build_env "capacitor"
print_env_vars "VITE_"
echo ""

# Test 2: Web environment
log_info "Test 2: Setting up Web environment..."
setup_build_env "web"
print_env_vars "VITE_"
echo ""

# Test 3: Production Capacitor environment
log_info "Test 3: Setting up Production Capacitor environment..."
setup_build_env "capacitor" "true"
print_env_vars "VITE_"
echo ""

# Test 4: Application directories
log_info "Test 4: Setting up application directories..."
setup_app_directories

# Test 5: Load .env file (if it exists)
log_info "Test 5: Loading .env file..."
load_env_file ".env"

# Test 6: Git hash
log_info "Test 6: Getting git hash..."
GIT_HASH=$(get_git_hash)
log_info "Git hash: $GIT_HASH"

# Print test summary
log_success "All environment variable tests completed successfully!"
print_footer "Environment Variable Test"

# Exit with success
exit 0 