# Simple test script for Nushell infrastructure
# Validates basic functionality without complex dependencies

export def test-basic-functionality []: nothing -> record {
    {
        nushell_version: (version | get version)
        current_time: (date now | format date "%Y-%m-%d %H:%M:%S")
        hostname: ($env.HOSTNAME? | default "unknown")
        user: ($env.USER? | default "unknown")
        working_directory: $env.PWD
        test_status: "passed"
    }
}

export def test-security-environment []: nothing -> record {
    {
        readonly_mode: ($env.NUSHELL_READONLY_MODE? | default "unknown")
        execution_mode: ($env.NUSHELL_EXECUTION_MODE? | default "unknown")
        audit_enabled: ($env.NUSHELL_AUDIT_ENABLED? | default "unknown")
        session_timeout: ($env.NUSHELL_SESSION_TIMEOUT? | default "unknown")
        test_status: "passed"
    }
}

export def test-file-operations []: nothing -> record {
    let test_results = {
        can_read_proc: (try { ls /proc | length } catch { 0 })
        can_read_tmp: (try { ls /tmp | length } catch { 0 })
        current_processes: (try { ps | length } catch { 0 })
        disk_usage: (try { df | length } catch { 0 })
        test_status: "completed"
    }

    $test_results
}

# Main test function
export def run-all-tests []: nothing -> record {
    let basic_test = (test-basic-functionality)
    let security_test = (test-security-environment)
    let file_test = (test-file-operations)

    {
        timestamp: (date now | format date "%Y-%m-%d %H:%M:%S")
        basic_functionality: $basic_test
        security_environment: $security_test
        file_operations: $file_test
        overall_status: "tests_completed"
    }
}