diff options
author | Guido Günther <agx@sigxcpu.org> | 2017-08-03 22:56:57 -0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2017-08-06 22:55:04 -0300 |
commit | cbacdfb40ca35633da06e9e05497ac0fb56cc4f9 (patch) | |
tree | 47498d3592bbe64ea9ef73575abc15f5b6dee7d8 /tests/component | |
parent | a5f22cbf94b3c51815449594c6d31db24664992e (diff) |
push: new command to push changes in one go
Closes: #733639
Diffstat (limited to 'tests/component')
-rw-r--r-- | tests/component/deb/test_push.py | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/tests/component/deb/test_push.py b/tests/component/deb/test_push.py new file mode 100644 index 00000000..641f63c6 --- /dev/null +++ b/tests/component/deb/test_push.py @@ -0,0 +1,109 @@ +# vim: set fileencoding=utf-8 : +# +# (C) 2017 Guido Günther <agx@sigxcpu.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, please see +# <http://www.gnu.org/licenses/> + +import subprocess + +from tests.component import ComponentTestBase + +from tests.component.deb.fixtures import RepoFixtures + +from gbp.git import GitRepository +from gbp.scripts.push import main as push + + +class TestPush(ComponentTestBase): + """Test pushing to remote repos""" + + def setUp(self): + ComponentTestBase.setUp(self) + self.target = GitRepository.create('target', bare=True) + + @RepoFixtures.native() + def test_push_native(self, repo): + repo.add_remote_repo('origin', self.target.path) + self.assertEquals(push(['argv0']), 0) + self._check_repo_state(self.target, 'master', + ['master'], + tags=['debian/0.4.14']) + self.assertEquals(repo.head, self.target.head) + + @RepoFixtures.quilt30() + def test_push_upstream(self, repo): + repo.add_remote_repo('origin', self.target.path) + self.assertEquals(push(['argv0']), 0) + self._check_repo_state(self.target, 'master', + ['master', 'upstream'], + tags=['debian/2.8-1', 'upstream/2.8']) + self.assertEquals(repo.head, self.target.head) + + @RepoFixtures.quilt30(opts=['--pristine-tar']) + def test_push_pristine_tar(self, repo): + repo.add_remote_repo('origin', self.target.path) + self.assertEquals(push(['argv0', '--pristine-tar']), 0) + self._check_repo_state(self.target, 'master', + ['master', 'upstream', 'pristine-tar'], + tags=['debian/2.8-1', 'upstream/2.8']) + self.assertEquals(repo.head, self.target.head) + + @RepoFixtures.native() + def test_push_tag_ne_branch(self, repo): + repo.add_remote_repo('origin', self.target.path) + self.add_file(repo, "foo.txt", "foo") + self.assertEquals(push(['argv0']), 0) + self._check_repo_state(self.target, 'master', + ['master'], + tags=['debian/0.4.14']) + self.assertEquals(repo.rev_parse("HEAD^"), + self.target.head) + + @RepoFixtures.quilt30() + def test_not_debian_branch(self, repo): + repo.add_remote_repo('origin', self.target.path) + repo.create_branch("foo") + repo.set_branch("foo") + self.assertEquals(push(['argv0']), 1) + self._check_log(-2, ".*You are not on branch 'master' but on 'foo'") + + @RepoFixtures.quilt30() + def test_dont_push_unreleased(self, repo): + repo.add_remote_repo('origin', self.target.path) + subprocess.check_call(["debchange", "-i", "foo"]) + self.assertEquals(push(['argv0']), 0) + self._check_repo_state(self.target, None, + ['upstream'], + tags=['upstream/2.8']) + + @RepoFixtures.quilt30() + def test_push_not_origin(self, repo): + repo.add_remote_repo('notorigin', self.target.path) + self.assertEquals(push(['argv0', 'notorigin']), 0) + self._check_repo_state(self.target, 'master', + ['master', 'upstream'], + tags=['debian/2.8-1', 'upstream/2.8']) + self.assertEquals(repo.head, self.target.head) + + @RepoFixtures.quilt30() + def test_push_not_origin_detect(self, repo): + repo.add_remote_repo('notorigin', self.target.path) + repo.set_config("branch.master.remote", "notorigin") + repo.set_config("branch.master.merge", "refs/heads/master") + self.assertEquals(push(['argv0']), 0) + self._check_repo_state(self.target, 'master', + ['master', 'upstream'], + tags=['debian/2.8-1', 'upstream/2.8']) + self.assertEquals(repo.head, self.target.head) |