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

Class TestBranchCreate

gitless/tests/test_core.py:771–804  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

769
770
771class TestBranchCreate(TestBranch):
772
773 def _assert_value_error(self, name, regexp):
774 self.assertRaisesRegexp(
775 ValueError, regexp, self.repo.create_branch, name,
776 self.repo.current_branch.head)
777
778 def test_create_invalid_name(self):
779 assert_invalid_name = lambda n: self._assert_value_error(n, 'not valid')
780 assert_invalid_name('')
781 assert_invalid_name('\t')
782 assert_invalid_name(' ')
783
784 def test_create_existent_name(self):
785 self.repo.create_branch('branch1', self.repo.current_branch.head)
786 self._assert_value_error('branch1', 'exists')
787
788 def test_create(self):
789 self.repo.create_branch('branch1', self.repo.current_branch.head)
790 self.repo.switch_current_branch(self.repo.lookup_branch('branch1'))
791 self.assertTrue(os.path.exists(TRACKED_FP))
792 self.assertEqual(TRACKED_FP_CONTENTS_2, utils_lib.read_file(TRACKED_FP))
793 self.assertFalse(os.path.exists(UNTRACKED_FP))
794 self.assertFalse(os.path.exists(IGNORED_FP))
795 self.assertFalse(os.path.exists('.gitignore'))
796
797 def test_create_from_prev_commit(self):
798 self.repo.create_branch('branch1', self.repo.revparse_single('HEAD^'))
799 self.repo.switch_current_branch(self.repo.lookup_branch('branch1'))
800 self.assertTrue(os.path.exists(TRACKED_FP))
801 self.assertEqual(TRACKED_FP_CONTENTS_1, utils_lib.read_file(TRACKED_FP))
802 self.assertFalse(os.path.exists(UNTRACKED_FP))
803 self.assertFalse(os.path.exists(IGNORED_FP))
804 self.assertFalse(os.path.exists('.gitignore'))
805
806
807class TestBranchDelete(TestBranch):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected