@@ -20,6 +20,36 @@ func TestMain(m *testing.M) {
20
20
unittest .MainTest (m )
21
21
}
22
22
23
+ func getExpectedGiteaContentsResponse () * api.ContentsResponse {
24
+ treePath := ".gitea"
25
+ sha := "b5f7dda5e39c1eef0d4da9c20b7d8322daa7add5"
26
+ encoding := ""
27
+ content := ""
28
+ selfURL := "https://try.gitea.io/api/v1/repos/user2/repo1/contents/" + treePath + "?ref=master"
29
+ htmlURL := "https://try.gitea.io/user2/repo1/src/branch/master/" + treePath
30
+ gitURL := "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/" + sha
31
+ downloadURL := "https://try.gitea.io/user2/repo1/raw/branch/master/" + treePath
32
+ return & api.ContentsResponse {
33
+ Name : treePath ,
34
+ Path : treePath ,
35
+ SHA : sha ,
36
+ LastCommitSHA : "94dc45d6ec51090b36c4d5bd5d9e6f5a70da9edf" ,
37
+ Type : "dir" ,
38
+ Size : 0 ,
39
+ Encoding : & encoding ,
40
+ Content : & content ,
41
+ URL : & selfURL ,
42
+ HTMLURL : & htmlURL ,
43
+ GitURL : & gitURL ,
44
+ DownloadURL : & downloadURL ,
45
+ Links : & api.FileLinksResponse {
46
+ Self : & selfURL ,
47
+ GitURL : & gitURL ,
48
+ HTMLURL : & htmlURL ,
49
+ },
50
+ }
51
+ }
52
+
23
53
func getExpectedReadmeContentsResponse () * api.ContentsResponse {
24
54
treePath := "README.md"
25
55
sha := "4b4851ad51df6a7d9f25c979345979eaeb5b349f"
@@ -32,7 +62,7 @@ func getExpectedReadmeContentsResponse() *api.ContentsResponse {
32
62
return & api.ContentsResponse {
33
63
Name : treePath ,
34
64
Path : treePath ,
35
- SHA : "4b4851ad51df6a7d9f25c979345979eaeb5b349f" ,
65
+ SHA : sha ,
36
66
LastCommitSHA : "65f1bf27bc3bf70f64657658635e66094edbcb4d" ,
37
67
Type : "file" ,
38
68
Size : 30 ,
@@ -96,7 +126,15 @@ func TestGetContentsOrListForDir(t *testing.T) {
96
126
readmeContentsResponse .Encoding = nil
97
127
readmeContentsResponse .Content = nil
98
128
129
+ giteaContentsResponse := getExpectedGiteaContentsResponse ()
130
+ // because will be in a list, doesn't have encoding and content
131
+ giteaContentsResponse .Encoding = nil
132
+ giteaContentsResponse .Content = nil
133
+ // because .gitea is a directory, doesn't have download url
134
+ giteaContentsResponse .DownloadURL = nil
135
+
99
136
expectedContentsListResponse := []* api.ContentsResponse {
137
+ giteaContentsResponse ,
100
138
readmeContentsResponse ,
101
139
}
102
140
0 commit comments