Skip to content

Commit 4a9d221

Browse files
authored
Fix pr 10323 (go-gitea#3)
* fix TESTS * leafe a note for fututre
1 parent 4d8dd1b commit 4a9d221

File tree

4 files changed

+4
-25
lines changed

4 files changed

+4
-25
lines changed

integrations/api_repo_file_delete_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,7 @@ func TestAPIDeleteFile(t *testing.T) {
113113
deleteFileOptions.SHA = "badsha"
114114
url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2)
115115
req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions)
116-
resp = session.MakeRequest(t, req, http.StatusInternalServerError)
117-
expectedAPIError := context.APIError{
118-
Message: "sha does not match [given: " + deleteFileOptions.SHA + ", expected: " + correctSHA + "]",
119-
URL: setting.API.SwaggerURL,
120-
}
121-
var apiError context.APIError
122-
DecodeJSON(t, resp, &apiError)
123-
assert.Equal(t, expectedAPIError, apiError)
116+
resp = session.MakeRequest(t, req, http.StatusNotFound)
124117

125118
// Test creating a file in repo16 by user4 who does not have write access
126119
fileID++

integrations/api_repo_get_contents_list_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,7 @@ func testAPIGetContentsList(t *testing.T, u *url.URL) {
139139
// Test file contents a file with a bad ref
140140
ref = "badref"
141141
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
142-
resp = session.MakeRequest(t, req, http.StatusInternalServerError)
143-
expectedAPIError := context.APIError{
144-
Message: "object does not exist [id: " + ref + ", rel_path: ]",
145-
URL: setting.API.SwaggerURL,
146-
}
147-
var apiError context.APIError
148-
DecodeJSON(t, resp, &apiError)
149-
assert.Equal(t, expectedAPIError, apiError)
142+
resp = session.MakeRequest(t, req, http.StatusNotFound)
150143

151144
// Test accessing private ref with user token that does not have access - should fail
152145
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)

integrations/api_repo_get_contents_test.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,7 @@ func testAPIGetContents(t *testing.T, u *url.URL) {
141141
// Test file contents a file with a bad ref
142142
ref = "badref"
143143
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?ref=%s", user2.Name, repo1.Name, treePath, ref)
144-
resp = session.MakeRequest(t, req, http.StatusInternalServerError)
145-
expectedAPIError := context.APIError{
146-
Message: "object does not exist [id: " + ref + ", rel_path: ]",
147-
URL: setting.API.SwaggerURL,
148-
}
149-
var apiError context.APIError
150-
DecodeJSON(t, resp, &apiError)
151-
assert.Equal(t, expectedAPIError, apiError)
144+
resp = session.MakeRequest(t, req, http.StatusNotFound)
152145

153146
// Test accessing private ref with user token that does not have access - should fail
154147
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo16.Name, treePath, token4)

routers/api/v1/repo/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ func DeleteFile(ctx *context.APIContext, apiOpts api.DeleteFileOptions) {
424424
}
425425
ctx.Error(http.StatusInternalServerError, "DeleteFile", err)
426426
} else {
427-
ctx.JSON(http.StatusOK, fileResponse)
427+
ctx.JSON(http.StatusOK, fileResponse) // FIXME on APIv2: return http.StatusNoContent
428428
}
429429
}
430430

0 commit comments

Comments
 (0)