#!/usr/bin/env python3
"""
Auto-generated CLI tests for env commands

Generated by: tests/generators/test_generator.py
DO NOT EDIT MANUALLY - Regenerate with: python tests/generators/test_generator.py

This file provides comprehensive coverage of env CLI commands, options,
and parameter combinations. Tests are automatically generated by introspecting
the Click command structure.
"""

import subprocess
import os

# Set testing environment variable
os.environ["N8N_DEPLOY_TESTING"] = "1"

CLI_COMMAND = ["./n8n-deploy"]


def test_env_help():
    """Test env --help"""
    result = subprocess.run(CLI_COMMAND + ["env", "--help"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: env --help\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
    assert "Usage:" in result.stdout or "Usage:" in result.stderr, (
        f"Expected 'Usage:' in output\n" f"stdout: {result.stdout[:500]}\n" f"stderr: {result.stderr[:500]}"
    )


def test_env_no_args():
    """Test env with no arguments"""
    result = subprocess.run(CLI_COMMAND + ["env"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: env\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_env_data_dir_valid_path():
    """Test env with valid --data-dir"""
    result = subprocess.run(CLI_COMMAND + ["env", "--data-dir", "/tmp"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: env --data-dir /tmp\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_env_output_json_flag():
    """Test env with --output-json flag"""
    result = subprocess.run(CLI_COMMAND + ["env", "--output-json"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: env --output-json\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )


def test_env_output_table_flag():
    """Test env with --output-table flag"""
    result = subprocess.run(CLI_COMMAND + ["env", "--output-table"], capture_output=True, text=True, timeout=60)
    assert result.returncode in [0, 1, 2], (
        f"Command failed with exit code {result.returncode}\n"
        f"Command: env --output-table\n"
        f"stdout: {result.stdout[:500]}\n"
        f"stderr: {result.stderr[:500]}"
    )
