from pathlib import Path
import tarfile
import io


def mock_cachito_tarball(create_at_path) -> str:
    """Create a mocked tarball for a remote source at the specified path."""
    create_at_path = Path(create_at_path)
    file_content = f"Content of {create_at_path.name}".encode("utf-8")

    readme = tarfile.TarInfo("app/README.txt")
    readme.size = len(file_content)

    with tarfile.open(create_at_path, 'w:gz') as tf:
        tf.addfile(readme, io.BytesIO(file_content))

    return str(create_at_path)