Skip to content

Commit

Permalink
Explicitly name initial branch in tests
Browse files Browse the repository at this point in the history
For systems that have init.defaultBranch set globally
  • Loading branch information
Viktor Dick committed Sep 30, 2023
1 parent 7473079 commit 06dad51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unreleased
* Omit title attributes if they are callable.
* Drop support for Python 2
* Explicitly name git branch in tests

22.2.4
* Refactor scripts into entry points to be usable with zc.buildout >= 3.
Expand Down
1 change: 1 addition & 0 deletions perfact/zodbsync/tests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self):
self.path = tempfile.mkdtemp()
commands = [
['init'],
['branch', '-m', 'main'],
['config', 'user.email', '[email protected]'],
['config', 'user.name', 'testrepo'],
]
Expand Down
26 changes: 13 additions & 13 deletions perfact/zodbsync/tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def envreset(self, request):
cmds = [
'reset --hard',
'clean -dfx',
'checkout master',
'checkout main',
'reset --hard {}'.format(self.initial_commit),
]
for cmd in cmds:
Expand All @@ -113,7 +113,7 @@ def envreset(self, request):
for line in output.strip().split('\n'):
commit, refname = line.split()
refname = refname[len('refs/heads/'):]
if refname != 'master':
if refname != 'main':
self.gitrun('branch', '-D', refname)

self.run('playback', '--skip-errors', '/')
Expand Down Expand Up @@ -726,7 +726,7 @@ def test_reset(self):
with open(path, 'w') as f:
f.writelines(lines)
self.gitrun('commit', '-a', '-m', 'Change title')
self.gitrun('checkout', 'master')
self.gitrun('checkout', 'main')
self.run('reset', 'second')
assert self.app.index_html.title == 'test'

Expand All @@ -744,11 +744,11 @@ def test_checkout(self):
Switch to another branch
"""
self.run('checkout', '-b', 'other')
# This switches back to master, but with a change
# This switches back to main, but with a change
self.test_reset()
self.run('checkout', 'other')
assert self.app.index_html.title != 'test'
self.run('checkout', 'master')
self.run('checkout', 'main')
assert self.app.index_html.title == 'test'

def test_exec_checkout(self):
Expand Down Expand Up @@ -993,8 +993,8 @@ def test_watch_structure_changes_and_playback_deleted_folder(self, conn):
def test_commit_on_branch_and_exec_merge(self):
'''
change to a git feature branch and create a
structure there, commit it and change back to the master branch
on master branch check if changes from feature arent existent,
structure there, commit it and change back to the main branch
on main branch check if changes from feature arent existent,
then merge feature branch and check if changes have been applied
correctly
'''
Expand All @@ -1012,8 +1012,8 @@ def test_commit_on_branch_and_exec_merge(self):
self.gitrun('add', '-A')
self.gitrun('commit', '-m', 'test case 3')

# checkout to master and check that changes are not yet existent
self.run('exec', 'git checkout master')
# checkout to main and check that changes are not yet existent
self.run('exec', 'git checkout main')
assert not os.path.isfile(self.meta_file_path(folder_1, s_folder_1))
assert folder_1 not in self.app.objectIds()

Expand Down Expand Up @@ -1058,11 +1058,11 @@ def test_failing_exec_commands(self):
with pytest.raises(subprocess.CalledProcessError):
self.run('exec', 'cherry-pick ThisIsDefinitelyNoCommit')

def test_create_multiple_commits_on_branch_and_pick_single_on_master(self):
def test_create_multiple_commits_on_branch_and_pick_single_on_main(self):
"""
create a feature branch on which
two changes will be commited to one commit each
change back to the master branch and use pick
change back to the main branch and use pick
to get the changes of that last commit
make sure only the last changes are present
"""
Expand All @@ -1089,8 +1089,8 @@ def test_create_multiple_commits_on_branch_and_pick_single_on_master(self):

commit = self.get_head_id()

# checkout master and check both changes aren't existent
self.run('exec', 'git checkout master')
# checkout main and check both changes aren't existent
self.run('exec', 'git checkout main')
assert not os.path.isfile(self.meta_file_path(folder_1))
assert folder_1 not in self.app.objectIds()
assert not os.path.isfile(self.meta_file_path(folder_2))
Expand Down

0 comments on commit 06dad51

Please sign in to comment.