Skip to content

Commit 91efd23

Browse files
committed
Test CheckoutCallbacks.checkout_progress
1 parent 08b2b40 commit 91efd23

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

test/test_repository.py

+9
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def __init__(self):
9999
super().__init__()
100100
self.conflicting_paths = set()
101101
self.updated_paths = set()
102+
self.completed_steps = -1
103+
self.total_steps = -1
102104

103105
def checkout_notify_flags(self) -> CheckoutNotify:
104106
return CheckoutNotify.CONFLICT | CheckoutNotify.UPDATED
@@ -109,12 +111,17 @@ def checkout_notify(self, why, path, baseline, target, workdir):
109111
elif why == CheckoutNotify.UPDATED:
110112
self.updated_paths.add(path)
111113

114+
def checkout_progress(self, path: str, completed_steps: int, total_steps: int):
115+
self.completed_steps = completed_steps
116+
self.total_steps = total_steps
117+
112118
# checkout i18n with conflicts and default strategy should not be possible
113119
callbacks = MyCheckoutCallbacks()
114120
with pytest.raises(pygit2.GitError):
115121
testrepo.checkout(ref_i18n, callbacks=callbacks)
116122
# make sure the callbacks caught that
117123
assert {'bye.txt'} == callbacks.conflicting_paths
124+
assert -1 == callbacks.completed_steps # shouldn't have done anything
118125

119126
# checkout i18n with GIT_CHECKOUT_FORCE
120127
head = testrepo.head
@@ -125,6 +132,8 @@ def checkout_notify(self, why, path, baseline, target, workdir):
125132
# make sure the callbacks caught the files affected by the checkout
126133
assert set() == callbacks.conflicting_paths
127134
assert {'bye.txt', 'new'} == callbacks.updated_paths
135+
assert callbacks.completed_steps > 0
136+
assert callbacks.completed_steps == callbacks.total_steps
128137

129138

130139
def test_checkout_aborted_from_callbacks(testrepo):

0 commit comments

Comments
 (0)