# HG changeset patch # User Marcin Kuzminski # Date 2018-01-15 18:13:54 # Node ID 32635607690fd7f9c3b00512c6332d5033a0a8dc # Parent 7cfaf3b12f59403e192742b624769cd6fdb6a2e5 tests: fixed tests for new source ref checking. diff --git a/rhodecode/tests/vcs/test_git.py b/rhodecode/tests/vcs/test_git.py --- a/rhodecode/tests/vcs/test_git.py +++ b/rhodecode/tests/vcs/test_git.py @@ -566,7 +566,8 @@ TODO: To be written... def test_maybe_prepare_merge_workspace(self): workspace = self.repo._maybe_prepare_merge_workspace( - 'pr2', Reference('branch', 'master', 'unused')) + 'pr2', Reference('branch', 'master', 'unused'), + Reference('branch', 'master', 'unused')) assert os.path.isdir(workspace) workspace_repo = GitRepository(workspace) @@ -574,12 +575,29 @@ TODO: To be written... # Calling it a second time should also succeed workspace = self.repo._maybe_prepare_merge_workspace( - 'pr2', Reference('branch', 'master', 'unused')) + 'pr2', Reference('branch', 'master', 'unused'), + Reference('branch', 'master', 'unused')) + assert os.path.isdir(workspace) + + def test_maybe_prepare_merge_workspace_different_refs(self): + workspace = self.repo._maybe_prepare_merge_workspace( + 'pr2', Reference('branch', 'master', 'unused'), + Reference('branch', 'develop', 'unused')) + + assert os.path.isdir(workspace) + workspace_repo = GitRepository(workspace) + assert workspace_repo.branches == self.repo.branches + + # Calling it a second time should also succeed + workspace = self.repo._maybe_prepare_merge_workspace( + 'pr2', Reference('branch', 'master', 'unused'), + Reference('branch', 'develop', 'unused')) assert os.path.isdir(workspace) def test_cleanup_merge_workspace(self): workspace = self.repo._maybe_prepare_merge_workspace( - 'pr3', Reference('branch', 'master', 'unused')) + 'pr3', Reference('branch', 'master', 'unused'), + Reference('branch', 'master', 'unused')) self.repo.cleanup_merge_workspace('pr3') assert not os.path.exists(workspace) diff --git a/rhodecode/tests/vcs/test_hg.py b/rhodecode/tests/vcs/test_hg.py --- a/rhodecode/tests/vcs/test_hg.py +++ b/rhodecode/tests/vcs/test_hg.py @@ -552,18 +552,21 @@ TODO: To be written... assert commit.message == merge_message def test_maybe_prepare_merge_workspace(self): - workspace = self.repo._maybe_prepare_merge_workspace('pr2', 'unused') + workspace = self.repo._maybe_prepare_merge_workspace( + 'pr2', 'unused', 'unused2') assert os.path.isdir(workspace) workspace_repo = MercurialRepository(workspace) assert workspace_repo.branches == self.repo.branches # Calling it a second time should also succeed - workspace = self.repo._maybe_prepare_merge_workspace('pr2', 'unused') + workspace = self.repo._maybe_prepare_merge_workspace( + 'pr2', 'unused', 'unused2') assert os.path.isdir(workspace) def test_cleanup_merge_workspace(self): - workspace = self.repo._maybe_prepare_merge_workspace('pr3', 'unused') + workspace = self.repo._maybe_prepare_merge_workspace( + 'pr3', 'unused', 'unused2') self.repo.cleanup_merge_workspace('pr3') assert not os.path.exists(workspace) diff --git a/rhodecode/tests/vcs/test_hg_vcsserver_cache_invalidation.py b/rhodecode/tests/vcs/test_hg_vcsserver_cache_invalidation.py --- a/rhodecode/tests/vcs/test_hg_vcsserver_cache_invalidation.py +++ b/rhodecode/tests/vcs/test_hg_vcsserver_cache_invalidation.py @@ -104,7 +104,7 @@ class TestMercurialRemoteRepoInvalidatio pr = PullRequestModel() workspace_id = pr._workspace_id(pull_request) shadow_repository_path = target_vcs._maybe_prepare_merge_workspace( - workspace_id, target_ref) + workspace_id, target_ref, source_ref) shadow_repo = target_vcs._get_shadow_instance(shadow_repository_path) # This will populate the cache of the mercurial repository object