Skip to content

Commit

Permalink
test(unit): Check that we can't fake the no-scope thing
Browse files Browse the repository at this point in the history
  • Loading branch information
igordertigor committed Aug 31, 2023
1 parent 62296b9 commit 289a338
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/unit/test_commit_parsing.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
from semv.interface import RawCommit, Commit
from semv.parse import AngularCommitParser
from semv import errors
from semv.parse import AngularCommitParser, InvalidCommitAction


class TestAngularCommitParser:
Expand All @@ -8,26 +10,42 @@ def test_non_breaking(self):
assert p.parse(
RawCommit(sha='any sha', title='feat(scope): Message', body='')
) == Commit(sha='any sha', type='feat', scope='scope', breaking=False)

def test_breaking(self):
p = AngularCommitParser()
assert p.parse(
RawCommit(sha='any sha', title='feat(scope): Message', body='BREAKING CHANGE: bla bla')
RawCommit(
sha='any sha',
title='feat(scope): Message',
body='BREAKING CHANGE: bla bla',
)
) == Commit(sha='any sha', type='feat', scope='scope', breaking=True)

def test_scope_may_include_underscore(self):
p = AngularCommitParser()
assert p.parse(
RawCommit(sha='any sha', title='feat(any_scope): Message', body='')
) == Commit(sha='any sha', type='feat', scope='any_scope', breaking=False)
) == Commit(
sha='any sha', type='feat', scope='any_scope', breaking=False
)

def test_scope_may_include_dash(self):
p = AngularCommitParser()
assert p.parse(
RawCommit(sha='any sha', title='feat(any-scope): Message', body='')
) == Commit(sha='any sha', type='feat', scope='any-scope', breaking=False)
) == Commit(
sha='any sha', type='feat', scope='any-scope', breaking=False
)

def test_no_scope(self):
p = AngularCommitParser()
assert p.parse(
RawCommit(sha='any sha', title='feat: No scope', body='')
) == Commit(sha='any sha', type='feat', scope=':global:', breaking=False)
) == Commit(
sha='any sha', type='feat', scope=':global:', breaking=False
)

def test_break_scope_with_no_parens(self):
p = AngularCommitParser(InvalidCommitAction.error)
with pytest.raises(errors.InvalidCommitFormat):
p.parse(RawCommit(sha='any sha', title='feat-notscope:', body=''))

0 comments on commit 289a338

Please sign in to comment.