# tests/test_pack_max_kb_each.py
from __future__ import annotations

from pathlib import Path

import oceansguard.cli as cli
from tests.conftest import _touch, _write, read_text, write_aiguard_yml


def test_pack_marks_too_large_files(tmp_path: Path, ux, patch_subprocess_for_pack):
    repo = tmp_path / "repo"
    repo.mkdir()

    _write(repo / "backend" / "app" / "main.py", "print('x')\n")
    _write(repo / "contracts" / "openapi.json", '{"openapi":"3.0.0","info":{"title":"t","version":"1"}}\n')
    _write(repo / "README.md", "# r\n")

    # 2KB のファイル（max_kb_each=1 にしてスキップに落とす）
    _touch(repo / "backend" / "app" / "big.txt", size_bytes=2 * 1024)

    write_aiguard_yml(repo, include_frontend_in_roots=False, max_files=200, max_kb_each=1)

    cli.cmd_pack(ux, repo, strict=False)

    txt = read_text(repo / "ai_context_pack.md")
    assert "backend/app/big.txt" in txt
    assert "(skipped: too large" in txt
