-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Do not show full lfs file on error in git_test.go:rawTest() #14980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do not show full lfs file on error in git_test.go:rawTest() #14980
Conversation
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]>
Signed-off-by: Andrew Thornton <[email protected]>
@@ -216,7 +216,10 @@ func rawTest(t *testing.T, ctx *APITestContext, little, big, littleLFS, bigLFS s | |||
req = NewRequest(t, "GET", path.Join("/", username, reponame, "/raw/branch/master/", littleLFS)) | |||
resp = session.MakeRequest(t, req, http.StatusOK) | |||
assert.NotEqual(t, littleSize, resp.Body.Len()) | |||
assert.Contains(t, resp.Body.String(), models.LFSMetaFileIdentifier) | |||
assert.LessOrEqual(t, resp.Body.Len(), 1024) | |||
if resp.Body.Len() != littleSize && resp.Body.Len() <= 1024 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is already asserted above, right?
Can't we check for the exact expected length?
Are there tests for small and large files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for the changes being the way they are is because of the contains below this line.
If the resp.Body does not contain the expected value it will be emitted whole into the test response.
This is bad and completely unreadable - we therefore need to skip doing that test in that case.
make lgtm work |
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]