Ejemplo n.º 1
0
def test_update_commit_message_regex_match_mode(mock_branch_name,
                                                branch_name, tmpdir):
    mock_branch_name.return_value = branch_name
    path = tmpdir.join('file.txt')
    path.write(COMMIT_MESSAGE)
    update_commit_message(six.text_type(path), r'[A-Z]+-\d+',
                          'regex_match', '{ticket}: {commit_msg}')
    assert path.read() == 'JIRA-1234: {message}'.format(message=COMMIT_MESSAGE)
Ejemplo n.º 2
0
def test_update_commit_message_no_modification(mock_branch_name, msg, tmpdir):
    mock_branch_name.return_value = 'JIRA-1234_new_feature'
    path = tmpdir.join('file.txt')
    path.write(msg)
    update_commit_message(six.text_type(path), r'[A-Z]+-\d+',
                          'underscore_split', '{ticket} {commit_msg}')
    # Message should remain intact as it contains some ticket
    assert path.read() == msg
Ejemplo n.º 3
0
def test_ci_message_with_nl_regex_match_mode(mock_branch_name, msg, tmpdir):
    first_line = msg.split('\n')[0].strip()
    mock_branch_name.return_value = "JIRA-239_mock_branch"
    path = tmpdir.join('file.txt')
    path.write(msg)
    update_commit_message(six.text_type(path), r'[A-Z]+-\d+',
                          'regex_match', '{commit_msg} - {ticket}')
    assert path.read().split('\n')[0] == "{first_line} - {ticket}".format(first_line=first_line, ticket="JIRA-239")
Ejemplo n.º 4
0
def test_update_commit_message_multiple_ticket_all_selected(
        mock_branch_name, test_data, tmpdir):
    mock_branch_name.return_value = test_data[0]
    path = tmpdir.join('file.txt')
    path.write(COMMIT_MESSAGE)
    update_commit_message(six.text_type(path), '[A-Z]+-\d+', 'regex_match',
                          '{tickets}: {commit_msg}')
    assert path.read() == '{expected_tickets}: {message}'.format(
        expected_tickets=test_data[1], message=COMMIT_MESSAGE)
Ejemplo n.º 5
0
def test_update_commit_message_underscore_split_mode(mock_branch_name,
                                                     test_data, tmpdir):
    mock_branch_name.return_value = test_data[0]
    path = tmpdir.join('file.txt')
    path.write(COMMIT_MESSAGE)
    update_commit_message(six.text_type(path), '[A-Z]+-\d+',
                          'underscore_split', '{ticket}: {commit_msg}')
    assert path.read() == '{expected_ticket}: {message}'.format(
        expected_ticket=test_data[1], message=COMMIT_MESSAGE)
Ejemplo n.º 6
0
def test_update_commit_message(mock_branch_name, msg, tmpdir):
    mock_branch_name.return_value = 'JIRA-1234_new_feature'
    path = tmpdir.join('file.txt')
    path.write(msg)
    update_commit_message(six.text_type(path), '[A-Z]+-\d+')
    assert 'JIRA-1234' in path.read()