#!/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 (development)
log_info "Test 1: Setting up Capacitor environment (development mode)..."
setup_build_env "capacitor" "development"
print_env_vars "VITE_"
echo ""

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

# Test 3: Capacitor test environment
log_info "Test 3: Setting up Capacitor environment (test mode)..."
setup_build_env "capacitor" "test"
print_env_vars "VITE_"
echo ""

# Test 4: Capacitor production environment
log_info "Test 4: Setting up Capacitor environment (production mode)..."
setup_build_env "capacitor" "production"
print_env_vars "VITE_"
echo ""

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

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

# Test 7: Git hash
log_info "Test 7: 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 