aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles/file_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 /modules/repofiles/file_test.go
parent738285a4aac5df2e60f4038aa79be3e9fe921bdb (diff)
downloadgitea-cd96dee9822c8b744526ba862fd8b5ec0e2c30ff.tar.gz
gitea-cd96dee9822c8b744526ba862fd8b5ec0e2c30ff.zip
Fixes #7292 - API File Contents bug (#7301)
Diffstat (limited to 'modules/repofiles/file_test.go')
-rw-r--r--modules/repofiles/file_test.go35
1 files changed, 23 insertions, 12 deletions
diff --git a/modules/repofiles/file_test.go b/modules/repofiles/file_test.go
index 5f6320a938..00feb93fff 100644
--- a/modules/repofiles/file_test.go
+++ b/modules/repofiles/file_test.go
@@ -5,6 +5,7 @@
package repofiles
import (
+ "code.gitea.io/gitea/modules/setting"
"testing"
"code.gitea.io/gitea/models"
@@ -16,21 +17,31 @@ import (
)
func getExpectedFileResponse() *api.FileResponse {
+ treePath := "README.md"
+ sha := "4b4851ad51df6a7d9f25c979345979eaeb5b349f"
+ encoding := "base64"
+ content := "IyByZXBvMQoKRGVzY3JpcHRpb24gZm9yIHJlcG8x"
+ 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{
- Name: "README.md",
- Path: "README.md",
- SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f",
+ Content: &api.ContentsResponse{
+ Name: treePath,
+ Path: treePath,
+ SHA: sha,
+ Type: "file",
Size: 30,
- URL: "https://try.gitea.io/api/v1/repos/user2/repo1/contents/README.md",
- HTMLURL: "https://try.gitea.io/user2/repo1/blob/master/README.md",
- GitURL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/4b4851ad51df6a7d9f25c979345979eaeb5b349f",
- DownloadURL: "https://try.gitea.io/user2/repo1/raw/branch/master/README.md",
- Type: "blob",
+ Encoding: &encoding,
+ Content: &content,
+ URL: &selfURL,
+ HTMLURL: &htmlURL,
+ GitURL: &gitURL,
+ DownloadURL: &downloadURL,
Links: &api.FileLinksResponse{
- Self: "https://try.gitea.io/api/v1/repos/user2/repo1/contents/README.md",
- GitURL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/4b4851ad51df6a7d9f25c979345979eaeb5b349f",
- HTMLURL: "https://try.gitea.io/user2/repo1/blob/master/README.md",
+ Self: &selfURL,
+ GitURL: &gitURL,
+ HTMLURL: &htmlURL,
},
},
Commit: &api.FileCommitResponse{