Skip to content

Commit 6463483

Browse files
authored
Do not show full lfs file on error in git_test.go:rawTest() (#14980)
If there is a problem uploading to LFS it is possible for the raw endpoint to return a very large file when a pointer file is expected This will then cause the drone logs to fill up unnecessarily with the contents of the very large file. If the file returned from raw is of the incorrect size we should therefore not test it see if it contains the pointer file and just declare that it is incorrect. Signed-off-by: Andrew Thornton <[email protected]>
1 parent 9566c9f commit 6463483

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

integrations/git_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
216216
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS))
217217
resp = session.MakeRequest(t, req, http.StatusOK)
218218
assert.NotEqual(t, littleSize, resp.Body.Len())
219-
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
219+
assert.LessOrEqual(t, resp.Body.Len(), 1024)
220+
if resp.Body.Len() != littleSize && resp.Body.Len() <= 1024 {
221+
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
222+
}
220223
}
221224

222225
if !testing.Short() {
@@ -228,7 +231,9 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s
228231
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", bigLFS))
229232
resp = session.MakeRequest(t, req, http.StatusOK)
230233
assert.NotEqual(t, bigSize, resp.Body.Len())
231-
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
234+
if resp.Body.Len() != bigSize && resp.Body.Len() <= 1024 {
235+
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier)
236+
}
232237
}
233238
}
234239
})

0 commit comments

Comments
 (0)