aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/api_repo_file_create_test.go
diff options
context:
space:
mode:
authorRichard Mahn <richmahn@users.noreply.github.com>2019-06-29 16:51:10 -0400
committertechknowlogick <techknowlogick@gitea.io>2019-06-29 16:51:10 -0400
commitcd96dee9822c8b744526ba862fd8b5ec0e2c30ff (patch)
treed7bbf2f2b7adf80b17f3ab3971ae49bae7b010c4 /integrations/api_repo_file_create_test.go
parent738285a4aac5df2e60f4038aa79be3e9fe921bdb (diff)
downloadgitea-cd96dee9822c8b744526ba862fd8b5ec0e2c30ff.tar.gz
gitea-cd96dee9822c8b744526ba862fd8b5ec0e2c30ff.zip
Fixes #7292 - API File Contents bug (#7301)
Diffstat (limited to 'integrations/api_repo_file_create_test.go')
-rw-r--r--integrations/api_repo_file_create_test.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/integrations/api_repo_file_create_test.go b/integrations/api_repo_file_create_test.go
index b00583c191..42898bf259 100644
--- a/integrations/api_repo_file_create_test.go
+++ b/integrations/api_repo_file_create_test.go
@@ -44,21 +44,29 @@ func getCreateFileOptions() api.CreateFileOptions {
func getExpectedFileResponseForCreate(commitID, treePath string) *api.FileResponse {
sha := "a635aa942442ddfdba07468cf9661c08fbdf0ebf"
+ encoding := "base64"
+ content := "VGhpcyBpcyBuZXcgdGV4dA=="
+ 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,
Size: 16,
- 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",
+ Type: "file",
+ 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{
@@ -145,11 +153,11 @@ func TestAPICreateFile(t *testing.T) {
var fileResponse api.FileResponse
DecodeJSON(t, resp, &fileResponse)
expectedSHA := "a635aa942442ddfdba07468cf9661c08fbdf0ebf"
- expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/blob/new_branch/new/file%d.txt", fileID)
+ expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/new/file%d.txt", fileID)
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/new/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, createFileOptions.Message+"\n", fileResponse.Commit.Message)
// Test creating a file without a message