From 038f183313f796dc0313c03d652a2bcc1698e78e Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 27 Oct 2009 20:46:26 +0100 Subject: implemented test for rejection handling and fixed a bug when parsing remote reference paths --- test/git/test_remote.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'test/git/test_remote.py') diff --git a/test/git/test_remote.py b/test/git/test_remote.py index ae828cbc..3b145468 100644 --- a/test/git/test_remote.py +++ b/test/git/test_remote.py @@ -17,13 +17,18 @@ class TestRemote(TestBase): fp.close() - def _check_fetch_results(self, results, remote): - self._print_fetchhead(remote.repo) + def _test_fetch_result(self, results, remote): + # self._print_fetchhead(remote.repo) assert len(results) > 0 and isinstance(results[0], remote.FetchInfo) - for result in results: - assert result.flags != 0 - assert isinstance(result.remote_ref, (SymbolicReference, Reference)) - # END for each result + for info in results: + assert info.flags != 0 + assert isinstance(info.remote_ref, (SymbolicReference, Reference)) + if info.flags & info.FORCED_UPDATE: + assert isinstance(info.commit_before_forced_update, Commit) + else: + assert info.commit_before_forced_update is None + # END forced update checking + # END for each info def _test_fetch_info(self, repo): self.failUnlessRaises(ValueError, Remote.FetchInfo._from_line, repo, "nonsense") @@ -33,10 +38,20 @@ class TestRemote(TestBase): # specialized fetch testing to de-clutter the main test self._test_fetch_info(rw_repo) - fetch_result = remote.fetch() - self._check_fetch_results(fetch_result, remote) + # put remote head to master as it is garantueed to exist + remote_repo.head.reference = remote_repo.heads.master + + res = remote.fetch() + self._test_fetch_result(res, remote) + + # rewind remote head to trigger rejection + # index must be false as remote is a bare repo + remote_repo.head.reset("HEAD~2", index=False) + res = remote.fetch() + self._test_fetch_result(res, remote) + master_info = res["%s/master" % remote] + assert master_info.flags & Remote.FetchInfo.FORCED_UPDATE and master_info.note is not None - self.fail("rejected parsing") self.fail("test parsing of each individual flag") self.fail("tag handling") -- cgit v1.2.1