summaryrefslogtreecommitdiffstats
path: root/gitlint/tests/contrib/rules/test_conventional_commit.py
diff options
context:
space:
mode:
Diffstat (limited to 'gitlint/tests/contrib/rules/test_conventional_commit.py')
-rw-r--r--gitlint/tests/contrib/rules/test_conventional_commit.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gitlint/tests/contrib/rules/test_conventional_commit.py b/gitlint/tests/contrib/rules/test_conventional_commit.py
index fb492df..5da5cd5 100644
--- a/gitlint/tests/contrib/rules/test_conventional_commit.py
+++ b/gitlint/tests/contrib/rules/test_conventional_commit.py
@@ -29,12 +29,34 @@ class ContribConventionalCommitTests(BaseTestCase):
violations = rule.validate("bår: foo", None)
self.assertListEqual([expected_violation], violations)
+ # assert violation when use strange chars after correct type
+ expected_violation = RuleViolation("CT1", "Title does not start with one of fix, feat, chore, docs,"
+ " style, refactor, perf, test, revert, ci, build",
+ "feat_wrong_chars: föo")
+ violations = rule.validate("feat_wrong_chars: föo", None)
+ self.assertListEqual([expected_violation], violations)
+
+ # assert violation when use strange chars after correct type
+ expected_violation = RuleViolation("CT1", "Title does not start with one of fix, feat, chore, docs,"
+ " style, refactor, perf, test, revert, ci, build",
+ "feat_wrong_chars(scope): föo")
+ violations = rule.validate("feat_wrong_chars(scope): föo", None)
+ self.assertListEqual([expected_violation], violations)
+
# assert violation on wrong format
expected_violation = RuleViolation("CT1", "Title does not follow ConventionalCommits.org format "
"'type(optional-scope): description'", "fix föo")
violations = rule.validate("fix föo", None)
self.assertListEqual([expected_violation], violations)
+ # assert no violation when use ! for breaking changes without scope
+ violations = rule.validate("feat!: föo", None)
+ self.assertListEqual([], violations)
+
+ # assert no violation when use ! for breaking changes with scope
+ violations = rule.validate("fix(scope)!: föo", None)
+ self.assertListEqual([], violations)
+
# assert no violation when adding new type
rule = ConventionalCommit({'types': ["föo", "bär"]})
for typ in ["föo", "bär"]:
@@ -45,3 +67,9 @@ class ContribConventionalCommitTests(BaseTestCase):
violations = rule.validate("fix: hür dur", None)
expected_violation = RuleViolation("CT1", "Title does not start with one of föo, bär", "fix: hür dur")
self.assertListEqual([expected_violation], violations)
+
+ # assert no violation when adding new type named with numbers
+ rule = ConventionalCommit({'types': ["föo123", "123bär"]})
+ for typ in ["föo123", "123bär"]:
+ violations = rule.validate(typ + ": hür dur", None)
+ self.assertListEqual([], violations)