예제 #1
0
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)
예제 #2
0
def cache(tmp_path: Path) -> Cache:
    """Return a cache."""
    return Cache(tmp_path / "cache")
예제 #3
0
def test_token_roundtrip(cache: Cache) -> None:
    """It saves and loads the token."""
    cache.save_token("token")
    assert "token" == cache.load_token()
예제 #4
0
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()
예제 #5
0
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
예제 #6
0
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