#!/usr/bin/env bats
# Test helper setup for bats-core
# Minimal helper without external bats libraries

# Common test variables
readonly TEST_TEMP_DIR=$(mktemp -d)
readonly PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"

# Cleanup function
cleanup() {
    rm -rf "$TEST_TEMP_DIR"
}

# Set up trap for cleanup
trap cleanup EXIT

# Simple assertion functions (bats-compatible)
assert_file_exists() {
    if [[ ! -f "$1" ]]; then
        echo "File does not exist: $1"
        return 1
    fi
}

assert_file_contains() {
    local file="$1"
    local content="$2"
    
    if ! grep -q "$content" "$file"; then
        echo "File '$file' does not contain '$content'"
        return 1
    fi
}

assert_regex() {
    local haystack="$1"
    local pattern="$2"
    
    if ! echo "$haystack" | grep -qE "$pattern"; then
        echo "Output does not match regex pattern '$pattern'"
        return 1
    fi
}

assert_equals() {
    local expected="$1"
    local actual="$2"
    
    if [[ "$expected" != "$actual" ]]; then
        echo "Expected '$expected' but got '$actual'"
        return 1
    fi
}

assert_success() {
    if [[ "$1" -ne 0 ]]; then
        echo "Command failed with exit code $1"
        return 1
    fi
}

assert_failure() {
    if [[ "$1" -eq 0 ]]; then
        echo "Command succeeded but should have failed"
        return 1
    fi
}
