MCPcopy Create free account
hub / github.com/gitless-vcs/gitless / TestBranchSwitch

Class TestBranchSwitch

gitless/tests/test_core.py:816–869  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814
815
816class TestBranchSwitch(TestBranch):
817
818 def test_switch_contents_still_there_untrack_tracked(self):
819 self.curr_b.untrack_file(TRACKED_FP)
820 utils_lib.write_file(TRACKED_FP, contents='contents')
821 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
822 self.assertEqual(TRACKED_FP_CONTENTS_2, utils_lib.read_file(TRACKED_FP))
823 self.repo.switch_current_branch(self.repo.lookup_branch('master'))
824 self.assertEqual('contents', utils_lib.read_file(TRACKED_FP))
825
826 def test_switch_contents_still_there_untracked(self):
827 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
828 utils_lib.write_file(UNTRACKED_FP, contents='contents')
829 self.repo.switch_current_branch(self.repo.lookup_branch('master'))
830 self.assertEqual(UNTRACKED_FP_CONTENTS, utils_lib.read_file(UNTRACKED_FP))
831 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
832 self.assertEqual('contents', utils_lib.read_file(UNTRACKED_FP))
833
834 def test_switch_contents_still_there_ignored(self):
835 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
836 utils_lib.write_file(IGNORED_FP, contents='contents')
837 self.repo.switch_current_branch(self.repo.lookup_branch('master'))
838 self.assertEqual(IGNORED_FP, utils_lib.read_file(IGNORED_FP))
839 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
840 self.assertEqual('contents', utils_lib.read_file(IGNORED_FP))
841
842 def test_switch_contents_still_there_tracked_commit(self):
843 utils_lib.write_file(TRACKED_FP, contents='commit')
844 git.commit(TRACKED_FP, m='comment')
845 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
846 self.assertEqual(TRACKED_FP_CONTENTS_2, utils_lib.read_file(TRACKED_FP))
847 self.repo.switch_current_branch(self.repo.lookup_branch('master'))
848 self.assertEqual('commit', utils_lib.read_file(TRACKED_FP))
849
850 def test_switch_file_classification_is_mantained(self):
851 self.curr_b.untrack_file(TRACKED_FP)
852 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
853 st = self.curr_b.status_file(TRACKED_FP)
854 self.assertTrue(st)
855 self.assertEqual(core.GL_STATUS_TRACKED, st.type)
856 self.repo.switch_current_branch(self.repo.lookup_branch('master'))
857 st = self.curr_b.status_file(TRACKED_FP)
858 self.assertTrue(st)
859 self.assertEqual(core.GL_STATUS_UNTRACKED, st.type)
860
861 def test_switch_with_hidden_files(self):
862 hf = '.file'
863 utils_lib.write_file(hf)
864 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
865 utils_lib.write_file(hf, contents='contents')
866 self.repo.switch_current_branch(self.repo.lookup_branch('master'))
867 self.assertEqual(hf, utils_lib.read_file(hf))
868 self.repo.switch_current_branch(self.repo.lookup_branch(BRANCH))
869 self.assertEqual('contents', utils_lib.read_file(hf))
870
871
872# Unit tests for remote related operations

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected