Skip to content

Commit 1ec1a66

Browse files
committed
t/t-push-failures-local.sh: drop extra assertions
Our t/t-push-failures-local.sh test script includes a number of tests which validate the behaviour of the "git push" command when Git LFS objects are missing or corrupt. While these tests are largely similar in their implementation, they vary in a number of formatting and implementation details unrelated to the specifics of the different conditions they simulate. These variations are artifacts of the evolution of our test suite over time; for example, the tests in the t/t-push-failures-local.sh script were refactored and collected from several earlier tests in commit 4d52e08 of PR git-lfs#3109. In a subsequent commit in this PR we expect to update the Git LFS client to remove some non-functional code which attempts to recreate missing Git LFS objects during push operations. In many cases this change will cause the client to report missing objects in an earlier stage of push operations than it does now. We also expect to reword the error message the client will output in such cases. Before we make these changes, we first revise the related tests in our test suite so they are as simple and similar as possible. This will ensure that when we update the Git LFS client we can clearly identify the changes that we need to make in our tests to accommodate the client's new behaviour. A pair of tests in the t/t-push-failures-local.sh script, specifically the "push reject missing objects (lfs.allowincompletepush default)" and "push reject corrupt objects (lfs.allowincompletepush default)" tests, perform a number of additional assertions beyond those performed by the other tests in the same script. These extra assertions first check that the tests' initial setup code has successfully created object files in the local Git LFS object storage directories, and then that the delete_local_object() and corrupt_local_object() test helper functions successfully delete or truncate one of the object files. However, these assertions are unnecessary, as the conditions they check are fully validated by the remainder of the tests' actions. For instance, we check the output of the "git push" command to confirm that one specific object is missing or corrupt, and then at the end of the tests we assert that only the remaining object has been pushed to the remote server. This final condition would not be possible if that object had not been successfully created in the first place. Therefore, in order to align these two tests with the other related tests we simply remove the unnecessary assertion statements. We can then also remove the setup code which initializes the variables that store the Git LFS object sizes, because these values were only used in the assertion calls.
1 parent 6dc0698 commit 1ec1a66

File tree

1 file changed

+0
-16
lines changed

1 file changed

+0
-16
lines changed

t/t-push-failures-local.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,18 @@ begin_test "push reject missing objects (lfs.allowincompletepush default)"
103103

104104
missing="missing"
105105
missing_oid="$(calc_oid "$missing")"
106-
missing_len="$(printf "%s" "$missing" | wc -c | awk '{ print $1 }')"
107106
printf "%s" "$missing" > missing.dat
108107
git add missing.dat
109108
git commit -m "add missing.dat"
110109

111110
present="present"
112111
present_oid="$(calc_oid "$present")"
113-
present_len="$(printf "%s" "$present" | wc -c | awk '{ print $1 }')"
114112
printf "%s" "$present" > present.dat
115113
git add present.dat
116114
git commit -m "add present.dat"
117115

118-
assert_local_object "$missing_oid" "$missing_len"
119-
assert_local_object "$present_oid" "$present_len"
120-
121116
delete_local_object "$missing_oid"
122117

123-
refute_local_object "$missing_oid"
124-
assert_local_object "$present_oid" "$present_len"
125-
126118
git push origin main 2>&1 | tee push.log
127119
if [ "1" -ne "${PIPESTATUS[0]}" ]; then
128120
echo >&2 "fatal: expected 'git push origin main' to fail ..."
@@ -151,26 +143,18 @@ begin_test "push reject corrupt objects (lfs.allowincompletepush default)"
151143

152144
corrupt="corrupt"
153145
corrupt_oid="$(calc_oid "$corrupt")"
154-
corrupt_len="$(printf "%s" "$corrupt" | wc -c | awk '{ print $1 }')"
155146
printf "%s" "$corrupt" > corrupt.dat
156147
git add corrupt.dat
157148
git commit -m "add corrupt.dat"
158149

159150
present="present"
160151
present_oid="$(calc_oid "$present")"
161-
present_len="$(printf "%s" "$present" | wc -c | awk '{ print $1 }')"
162152
printf "%s" "$present" > present.dat
163153
git add present.dat
164154
git commit -m "add present.dat"
165155

166-
assert_local_object "$corrupt_oid" "$corrupt_len"
167-
assert_local_object "$present_oid" "$present_len"
168-
169156
corrupt_local_object "$corrupt_oid"
170157

171-
refute_local_object "$corrupt_oid" "$corrupt_len"
172-
assert_local_object "$present_oid" "$present_len"
173-
174158
git push origin main 2>&1 | tee push.log
175159
if [ "1" -ne "${PIPESTATUS[0]}" ]; then
176160
echo >&2 "fatal: expected 'git push origin main' to fail ..."

0 commit comments

Comments
 (0)