Beispiel #1
0
def test_negative_git():
    """
    test negative git command
    """
    try:
        git("blah")
    except Exception as ex:
        assert not isinstance(ex, NotGitRepoError)
Beispiel #2
0
def test_NotGitRepoError():
    """
    NotGitRepoError
    """
    with cd(NON_GIT_REPO_PATH):
        try:
            git("rev-parse HEAD")
            result = False
        except NotGitRepoError:
            result = True
    assert result
Beispiel #3
0
def test_REVISION():
    """
    version
    """
    assert CFG.REVISION == git("rev-parse HEAD")
    with cd(NON_GIT_REPO_PATH):
        os.environ["REVISION"] = "REVISION"
        assert CFG.REVISION == "REVISION"
Beispiel #4
0
def test_BRANCH():
    """
    branch
    """
    assert CFG.BRANCH == git("rev-parse --abbrev-ref HEAD")
    with cd(NON_GIT_REPO_PATH):
        os.environ["BRANCH"] = "BRANCH"
        assert CFG.BRANCH == "BRANCH"
Beispiel #5
0
def test_VERSION():
    """
    version
    """
    assert CFG.VERSION == git("describe --abbrev=7 --always")
    with cd(NON_GIT_REPO_PATH):
        os.environ["VERSION"] = "VERSION"
        assert CFG.VERSION == "VERSION"
Beispiel #6
0
def test_REMOTE_ORIGIN_URL():
    """
    remote origin url
    """
    assert CFG.REMOTE_ORIGIN_URL == git("config --get remote.origin.url")
    with cd(NON_GIT_REPO_PATH):
        os.environ["REMOTE_ORIGIN_URL"] = "REMOTE_ORIGIN_URL"
        assert CFG.REMOTE_ORIGIN_URL == "REMOTE_ORIGIN_URL"
Beispiel #7
0
def test_LS_REMOTE():
    """
    ls-remote
    """
    result = git(f"ls-remote https://github.com/{CFG.REPO_NAME}")
    assert CFG.LS_REMOTE == {
        refname: revision
        for revision, refname in [line.split() for line in result.split("\n")]
    }
    with cd(NON_GIT_REPO_PATH):
        try:
            os.environ["REPO_NAME"] = "mozilla/subhub"
            CFG.LS_REMOTE
            assert False
        except Exception as ex:
            assert isinstance(ex, NotGitRepoError)
Beispiel #8
0
def test_REPO_ROOT():
    """
    repo_root
    """
    assert CFG.REPO_ROOT == git("rev-parse --show-toplevel")