diff options
author | Richard Mahn <richmahn@users.noreply.github.com> | 2019-06-29 16:51:10 -0400 |
---|---|---|
committer | techknowlogick <techknowlogick@gitea.io> | 2019-06-29 16:51:10 -0400 |
commit | cd96dee9822c8b744526ba862fd8b5ec0e2c30ff (patch) | |
tree | d7bbf2f2b7adf80b17f3ab3971ae49bae7b010c4 /integrations/api_repo_file_update_test.go | |
parent | 738285a4aac5df2e60f4038aa79be3e9fe921bdb (diff) | |
download | gitea-cd96dee9822c8b744526ba862fd8b5ec0e2c30ff.tar.gz gitea-cd96dee9822c8b744526ba862fd8b5ec0e2c30ff.zip |
Fixes #7292 - API File Contents bug (#7301)
Diffstat (limited to 'integrations/api_repo_file_update_test.go')
-rw-r--r-- | integrations/api_repo_file_update_test.go | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/integrations/api_repo_file_update_test.go b/integrations/api_repo_file_update_test.go index 17fa2adb26..366eb5e918 100644 --- a/integrations/api_repo_file_update_test.go +++ b/integrations/api_repo_file_update_test.go @@ -47,21 +47,29 @@ func getUpdateFileOptions() *api.UpdateFileOptions { func getExpectedFileResponseForUpdate(commitID, treePath string) *api.FileResponse { sha := "08bd14b2e2852529157324de9c226b3364e76136" + encoding := "base64" + content := "VGhpcyBpcyB1cGRhdGVkIHRleHQ=" + selfURL := setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath + "?ref=master" + htmlURL := setting.AppURL + "user2/repo1/src/branch/master/" + treePath + gitURL := setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha + downloadURL := setting.AppURL + "user2/repo1/raw/branch/master/" + treePath return &api.FileResponse{ - Content: &api.FileContentResponse{ + Content: &api.ContentsResponse{ Name: filepath.Base(treePath), Path: treePath, SHA: sha, + Type: "file", Size: 20, - URL: setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath, - HTMLURL: setting.AppURL + "user2/repo1/blob/master/" + treePath, - GitURL: setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha, - DownloadURL: setting.AppURL + "user2/repo1/raw/branch/master/" + treePath, - Type: "blob", + Encoding: &encoding, + Content: &content, + URL: &selfURL, + HTMLURL: &htmlURL, + GitURL: &gitURL, + DownloadURL: &downloadURL, Links: &api.FileLinksResponse{ - Self: setting.AppURL + "api/v1/repos/user2/repo1/contents/" + treePath, - GitURL: setting.AppURL + "api/v1/repos/user2/repo1/git/blobs/" + sha, - HTMLURL: setting.AppURL + "user2/repo1/blob/master/" + treePath, + Self: &selfURL, + GitURL: &gitURL, + HTMLURL: &htmlURL, }, }, Commit: &api.FileCommitResponse{ @@ -150,11 +158,11 @@ func TestAPIUpdateFile(t *testing.T) { var fileResponse api.FileResponse DecodeJSON(t, resp, &fileResponse) expectedSHA := "08bd14b2e2852529157324de9c226b3364e76136" - expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/blob/new_branch/update/file%d.txt", fileID) + expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/update/file%d.txt", fileID) expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/update/file%d.txt", fileID) assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) - assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL) - assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL) + 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 @@ -170,11 +178,11 @@ func TestAPIUpdateFile(t *testing.T) { resp = session.MakeRequest(t, req, http.StatusOK) DecodeJSON(t, resp, &fileResponse) expectedSHA = "08bd14b2e2852529157324de9c226b3364e76136" - expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/blob/master/rename/update/file%d.txt", fileID) + expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID) expectedDownloadURL = fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/master/rename/update/file%d.txt", fileID) assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA) - assert.EqualValues(t, expectedHTMLURL, fileResponse.Content.HTMLURL) - assert.EqualValues(t, expectedDownloadURL, fileResponse.Content.DownloadURL) + assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL) + assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL) // Test updating a file without a message updateFileOptions = getUpdateFileOptions() |