mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 02:46:04 +01:00 
			
		
		
		
	Contents API should return 404 on not exist (#10323)
* Return 404 on not exist * swagger update and use git.IsErrNotExist * Handle delete too * Handle delete too x2 * Fix pr 10323 (#3) * fix TESTS * leafe a note for fututre * placate golangci-lint Signed-off-by: Andrew Thornton <art27@cantab.net> * Update integrations/api_repo_file_delete_test.go Co-Authored-By: 6543 <6543@obermui.de> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
This commit is contained in:
		| @@ -11,8 +11,6 @@ import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"code.gitea.io/gitea/models" | ||||
| 	"code.gitea.io/gitea/modules/context" | ||||
| 	"code.gitea.io/gitea/modules/setting" | ||||
| 	api "code.gitea.io/gitea/modules/structs" | ||||
|  | ||||
| 	"github.com/stretchr/testify/assert" | ||||
| @@ -109,18 +107,10 @@ func TestAPIDeleteFile(t *testing.T) { | ||||
| 		treePath = fmt.Sprintf("delete/file%d.txt", fileID) | ||||
| 		createFile(user2, repo1, treePath) | ||||
| 		deleteFileOptions = getDeleteFileOptions() | ||||
| 		correctSHA := deleteFileOptions.SHA | ||||
| 		deleteFileOptions.SHA = "badsha" | ||||
| 		url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) | ||||
| 		req = NewRequestWithJSON(t, "DELETE", url, &deleteFileOptions) | ||||
| 		resp = session.MakeRequest(t, req, http.StatusInternalServerError) | ||||
| 		expectedAPIError := context.APIError{ | ||||
| 			Message: "sha does not match [given: " + deleteFileOptions.SHA + ", expected: " + correctSHA + "]", | ||||
| 			URL:     setting.API.SwaggerURL, | ||||
| 		} | ||||
| 		var apiError context.APIError | ||||
| 		DecodeJSON(t, resp, &apiError) | ||||
| 		assert.Equal(t, expectedAPIError, apiError) | ||||
| 		resp = session.MakeRequest(t, req, http.StatusBadRequest) | ||||
|  | ||||
| 		// Test creating a file in repo16 by user4 who does not have write access | ||||
| 		fileID++ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user