"""Tests for nexus-files sudoers template and batch patch helpers."""

from server.application.services.files_sudoers_service import build_nexus_files_sudoers


def test_build_nexus_files_sudoers_includes_rsync():
    content = build_nexus_files_sudoers("ubuntu")
    assert "ubuntu ALL=(root) NOPASSWD:" in content
    assert "/usr/bin/rsync" in content
    assert "/bin/rsync" in content
    assert "/usr/bin/chmod" in content


def test_build_nexus_files_sudoers_strips_user():
    content = build_nexus_files_sudoers("  deploy  ")
    assert content.startswith("# nexus-files:")
    assert "deploy ALL=(root)" in content
