diff options
author | Richard Mahn <richmahn@users.noreply.github.com> | 2019-06-29 11:19:24 -0400 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-06-29 16:19:24 +0100 |
commit | 002b597c1f87cd5c69d32053a62f57c08d48d3ee (patch) | |
tree | c14ccd9f1a1b02e21759a4fcae569d8c8116df4f /integrations/api_repo_file_update_test.go | |
parent | 462284e2f5768cf04d71c7abd8c01eef20cff73d (diff) | |
download | gitea-002b597c1f87cd5c69d32053a62f57c08d48d3ee.tar.gz gitea-002b597c1f87cd5c69d32053a62f57c08d48d3ee.zip |
Fixes #7152 - Allow create/update/delete message to be empty, use default message (#7324)
* Fixes #7152 - Allow create/update/delete message to be empty, use default message
* Linting fix
* Fix to delete integration tests
Diffstat (limited to 'integrations/api_repo_file_update_test.go')
-rw-r--r-- | integrations/api_repo_file_update_test.go | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/integrations/api_repo_file_update_test.go b/integrations/api_repo_file_update_test.go index 90fecf59d0..17fa2adb26 100644 --- a/integrations/api_repo_file_update_test.go +++ b/integrations/api_repo_file_update_test.go @@ -25,8 +25,23 @@ func getUpdateFileOptions() *api.UpdateFileOptions { content := "This is updated text" contentEncoded := base64.StdEncoding.EncodeToString([]byte(content)) return &api.UpdateFileOptions{ - DeleteFileOptions: *getDeleteFileOptions(), - Content: contentEncoded, + DeleteFileOptions: api.DeleteFileOptions{ + FileOptions: api.FileOptions{ + BranchName: "master", + NewBranchName: "master", + Message: "My update of new/file.txt", + Author: api.Identity{ + Name: "John Doe", + Email: "johndoe@example.com", + }, + Committer: api.Identity{ + Name: "Jane Doe", + Email: "janedoe@example.com", + }, + }, + SHA: "103ff9234cefeee5ec5361d22b49fbb04d385885", + }, + Content: contentEncoded, } } @@ -67,7 +82,7 @@ func getExpectedFileResponseForUpdate(commitID, treePath string) *api.FileRespon Email: "johndoe@example.com", }, }, - Message: "Updates README.md\n", + Message: "My update of README.md\n", }, Verification: &api.PayloadCommitVerification{ Verified: false, @@ -140,6 +155,7 @@ func TestAPIUpdateFile(t *testing.T) { assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL) assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL) + assert.EqualValues(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message) // Test updating a file and renaming it updateFileOptions = getUpdateFileOptions() @@ -160,6 +176,20 @@ func TestAPIUpdateFile(t *testing.T) { assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL) assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL) + // Test updating a file without a message + updateFileOptions = getUpdateFileOptions() + updateFileOptions.Message = "" + updateFileOptions.BranchName = repo1.DefaultBranch + fileID++ + treePath = fmt.Sprintf("update/file%d.txt", fileID) + createFile(user2, repo1, treePath) + url = fmt.Sprintf("/api/v1/repos/%s/%s/contents/%s?token=%s", user2.Name, repo1.Name, treePath, token2) + req = NewRequestWithJSON(t, "PUT", url, &updateFileOptions) + resp = session.MakeRequest(t, req, http.StatusOK) + DecodeJSON(t, resp, &fileResponse) + expectedMessage := "Update '" + treePath + "'\n" + assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message) + // Test updating a file with the wrong SHA fileID++ treePath = fmt.Sprintf("update/file%d.txt", fileID) |