"""Unit coverage for the public wildcard-secret version label."""

import sys
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parents[2] / "runner"))
import warm_reconcile as wr  # noqa: E402


def test_wildcard_secret_version_is_stable_and_does_not_need_key(tmp_path):
    (tmp_path / "fullchain.pem").write_text("public certificate chain\n")
    assert wr.wildcard_secret_version(str(tmp_path)) == wr.wildcard_secret_version(str(tmp_path))
    assert wr.wildcard_secret_version(str(tmp_path)).startswith("v")


def test_wildcard_secret_version_changes_with_certificate_chain(tmp_path):
    chain = tmp_path / "fullchain.pem"
    chain.write_text("first public certificate chain\n")
    first = wr.wildcard_secret_version(str(tmp_path))
    chain.write_text("replacement public certificate chain\n")
    assert wr.wildcard_secret_version(str(tmp_path)) != first
