Skip to content

Commit

Permalink
Explicitly name initial branch in tests (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
viktordick committed Nov 2, 2023
1 parent 2c555a6 commit 36b0a58
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
unreleased
* Explicitly name git branch in tests

22.2.5
* Omit title attributes if they are callable.
* Drop support for Python 2
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', 'autotest'],
['config', 'user.email', 'test@zodbsync.org'],
['config', 'user.name', 'testrepo'],
]
Expand Down
28 changes: 15 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 autotest',
'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 != 'autotest':
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', 'autotest')
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 autotest, 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', 'autotest')
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 autotest branch
on autotest 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 autotest and check that changes are not yet existent
self.run('exec', 'git checkout autotest')
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,13 @@ 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_autotest(
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 autotest branch and use pick
to get the changes of that last commit
make sure only the last changes are present
"""
Expand All @@ -1089,8 +1091,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 autotest and check both changes aren't existent
self.run('exec', 'git checkout autotest')
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 36b0a58

Please sign in to comment.