"""Tests for the huntpdf CLI stub."""

import subprocess
import sys

from huntpdf.cli import main


def test_stub_echoes_query(capsys):
    main(["10.1234/test"])
    assert capsys.readouterr().out.strip() == "10.1234/test"


def test_stub_echoes_arxiv_id(capsys):
    main(["2301.00001"])
    assert capsys.readouterr().out.strip() == "2301.00001"


def test_stub_echoes_url(capsys):
    main(["https://arxiv.org/abs/2301.00001"])
    assert capsys.readouterr().out.strip() == "https://arxiv.org/abs/2301.00001"


def test_entrypoint_runs():
    result = subprocess.run(
        [sys.executable, "-m", "huntpdf.cli", "test-query"],
        capture_output=True,
        text=True,
    )
    assert result.returncode == 0
    assert result.stdout.strip() == "test-query"
