#!/usr/bin/env bash

# Source common functions
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
source "${SCRIPT_DIR}/common.sh"

# Container execution script for unit tests
# This script is designed to be run inside a Docker container

main() {
    log "Starting containerized unit test execution..."
    
    # Set up paths for container environment
    export PATH=$PATH:~:/
    export ASSET_DIR=/
    
    log "Script path: $SCRIPT_DIR"
    log "PATH: $PATH"
    
    # Change to project directory
    cd tici || {
        log_error "Failed to change to tici directory"
        exit 1
    }
    
    # Run unit tests using the ut-run.sh script
    log "Executing unit test runner..."
    if "$SCRIPT_DIR/ut-run.sh"; then
        log "Unit tests completed successfully in container! 🎉"
        exit 0
    else
        log_error "Unit tests failed in container"
        exit 1
    fi
}

# Execute main function
main "$@"
