diff options
author | Tim Harder <radhermit@gmail.com> | 2021-03-11 22:21:27 -0700 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2021-03-11 22:22:15 -0700 |
commit | 49dc963d05209092628f19d9b7a4e37ef17a168e (patch) | |
tree | 1859e2330039c0876e43266e1709d03acb8b85f8 /tests | |
parent | tests: add check for -M/--message-template (diff) | |
download | pkgdev-49dc963d05209092628f19d9b7a4e37ef17a168e.tar.gz pkgdev-49dc963d05209092628f19d9b7a4e37ef17a168e.tar.bz2 pkgdev-49dc963d05209092628f19d9b7a4e37ef17a168e.zip |
tests: check empty message template file
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scripts/test_pkgdev_commit.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py index 29903e2..15de1d5 100644 --- a/tests/scripts/test_pkgdev_commit.py +++ b/tests/scripts/test_pkgdev_commit.py @@ -184,7 +184,7 @@ class TestPkgdevCommit: commit_msg = git_repo.log(['-1', '--pretty=tformat:%B', 'HEAD']) assert commit_msg == ['commit2'] - def test_message_template(self, repo, make_git_repo, tmp_path): + def test_message_template(self, capsys, repo, make_git_repo, tmp_path): git_repo = make_git_repo(repo.location) repo.create_ebuild('cat/pkg-0') git_repo.add_all('cat/pkg-0') @@ -228,6 +228,22 @@ class TestPkgdevCommit: commit_msg = git_repo.log(['-1', '--pretty=tformat:%B', 'HEAD']) assert commit_msg == ['prefix: summary', '', 'body'] + # empty message + with open(path, 'w') as f: + f.write('') + + for i, opt in enumerate(['-M', '--message-template'], 5): + repo.create_ebuild(f'cat/pkg-{i}') + git_repo.add_all(f'cat/pkg-{i}', commit=False) + with patch('sys.argv', self.args + ['-u', opt, path]), \ + pytest.raises(SystemExit) as excinfo, \ + chdir(git_repo.path): + self.script() + assert excinfo.value.code == 2 + out, err = capsys.readouterr() + assert not out + assert err.strip().startswith('pkgdev commit: error: empty message template') + def test_custom_unprefixed_message(self, capsys, repo, make_git_repo): git_repo = make_git_repo(repo.location) ebuild_path = repo.create_ebuild('cat/pkg-0') |