def test_get_token_from_cache(cache: Cache) -> None: """It loads the token from the cache.""" cache.save_token("token") assert "token" == __main__.get_token(cache)
def cache(tmp_path: Path) -> Cache: """Return a cache.""" return Cache(tmp_path / "cache")
def test_token_roundtrip(cache: Cache) -> None: """It saves and loads the token.""" cache.save_token("token") assert "token" == cache.load_token()
def test_worktree(cache: Cache, url: str) -> None: """It creates a worktree for the given branch.""" repository = cache.repository(url) with cache.worktree(repository, "branch") as worktree: assert "branch" == worktree.get_current_branch()
def test_repository_idempotent(cache: Cache, url: str) -> None: """It returns the same repository as before.""" clone1 = cache.repository(url) clone2 = cache.repository(url) assert clone1.path == clone2.path
def test_repository_clone(cache: Cache, url: str) -> None: """It clones the repository within the cache directory.""" clone = cache.repository(url) assert cache.path in clone.path.parents