| 1 | from qa.base import BaseTestCase |
| 2 | from qa.shell import gitlint |
| 3 | |
| 4 | |
| 5 | class ContribRuleTests(BaseTestCase): |
| 6 | """Integration tests for contrib rules.""" |
| 7 | |
| 8 | def test_contrib_rules(self): |
| 9 | self.create_simple_commit("WIP Thi$ is å title\n\nMy bödy that is a bit longer than 20 chars") |
| 10 | output = gitlint( |
| 11 | "--contrib", "contrib-title-conventional-commits,CC1", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[3] |
| 12 | ) |
| 13 | self.assertEqualStdout(output, self.get_expected("test_contrib/test_contrib_rules_1")) |
| 14 | |
| 15 | def test_contrib_rules_with_config(self): |
| 16 | self.create_simple_commit("WIP Thi$ is å title\n\nMy bödy that is a bit longer than 20 chars") |
| 17 | output = gitlint( |
| 18 | "--contrib", |
| 19 | "contrib-title-conventional-commits,CC1", |
| 20 | "-c", |
| 21 | "contrib-title-conventional-commits.types=föo,bår", |
| 22 | _cwd=self.tmp_git_repo, |
| 23 | _tty_in=True, |
| 24 | _ok_code=[3], |
| 25 | ) |
| 26 | self.assertEqualStdout(output, self.get_expected("test_contrib/test_contrib_rules_with_config_1")) |
| 27 | |
| 28 | def test_invalid_contrib_rules(self): |
| 29 | self.create_simple_commit("WIP: test") |
| 30 | output = gitlint("--contrib", "föobar,CC1", _cwd=self.tmp_git_repo, _tty_in=True, _ok_code=[255]) |
| 31 | self.assertEqualStdout(output, "Config Error: No contrib rule with id or name 'föobar' found.\n") |