"""Tests for file_reader skill."""

import tempfile
from pathlib import Path

from skill import run


def test_read_existing_file():
    with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
        f.write("hello world")
        f.flush()
        result = run(f.name)
    assert result["content"] == "hello world"
    assert result["size_bytes"] == 11
    Path(f.name).unlink()


def test_read_missing_file():
    import pytest

    with pytest.raises(FileNotFoundError):
        run("/tmp/nonexistent_alive_test_file.txt")


def test_read_too_large():
    import pytest

    with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
        f.write("x" * 100)
        f.flush()
        with pytest.raises(ValueError, match="too large"):
            run(f.name, max_bytes=10)
    Path(f.name).unlink()
