コード例 #1
0
def test_index_init():
    commit1 = Mock()
    commit2 = Mock()
    tagref1 = Mock(commit=commit1)
    tagref2 = Mock(commit=commit2)
    tagref3 = Mock(commit=commit2)
    repo_mock = Mock(spec=Repo, tags=[tagref1, tagref2, tagref3])

    index = GitRepository._init_commit_tags_index(repo_mock)
    assert index == {commit1: [tagref1], commit2: [tagref2, tagref3]}
コード例 #2
0
def test_index_init():
    commit1 = Mock()
    commit2 = Mock()
    tagref1 = Mock()
    tagref1.commit = commit1
    tagref1.name = "a"
    tagref2 = Mock()
    tagref2.commit = commit2
    tagref2.name = "b"
    tagref3 = Mock()
    tagref3.commit = commit2
    tagref3.name = "c"
    repo_mock = Mock(spec=Repo, tags=[tagref1, tagref2, tagref3])

    index = GitRepository._init_commit_tags_index(repo_mock, r".*")
    assert index == {commit1: [tagref1], commit2: [tagref2, tagref3]}
コード例 #3
0
def test_tag_pattern(tags, tag_prefix, tag_pattern, expected_tags):
    tag_refs = []
    for tag in tags:
        tag_ref = Mock(commit=Mock())
        tag_ref.name = tag
        tag_refs.append(tag_ref)

    repo_mock = Mock(spec=Repo, tags=tag_refs)

    selected_tag_refs = GitRepository._init_commit_tags_index(repo_mock, tag_prefix, tag_pattern)

    selected_tags = []
    for selected_tag_ref_list in selected_tag_refs.values():
        for selected_tag_ref in selected_tag_ref_list:
            selected_tags.append(selected_tag_ref.name)

    assert sorted(selected_tags) == sorted(expected_tags)
コード例 #4
0
def test_index_init():
    commit1 = Mock()
    commit2 = Mock()
    tagref1 = Mock(commit=commit1)
    tagref1.name = "1.0.0"
    tagref2 = Mock(commit=commit2)
    tagref2.name = "2.0.0"
    tagref3 = Mock(commit=commit2)
    tagref3.name = "2.0.0"

    repo_mock = Mock(spec=Repo, tags=[tagref1, tagref2, tagref3])

    # no prefix
    tag_prefix = ""
    # we are using default tag pattern => semantic versioning
    tag_pattern = None

    index = GitRepository._init_commit_tags_index(repo_mock, tag_prefix, tag_pattern)
    assert index == {commit1: [tagref1], commit2: [tagref2, tagref3]}