@@ -108,7 +108,7 @@ func getExpectedFileResponseForRepofilesDelete() *api.FileResponse {
108108 }
109109}
110110
111- func getExpectedFileResponseForRepofilesCreate (commitID , lastCommitSHA string ) * api.FileResponse {
111+ func getExpectedFileResponseForRepofilesCreate (commitID , lastCommitSHA string , lastCommitWhen time. Time ) * api.FileResponse {
112112 treePath := "new/file.txt"
113113 encoding := "base64"
114114 content := "VGhpcyBpcyBhIE5FVyBmaWxl"
@@ -118,18 +118,19 @@ func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *
118118 downloadURL := setting .AppURL + "user2/repo1/raw/branch/master/" + treePath
119119 return & api.FileResponse {
120120 Content : & api.ContentsResponse {
121- Name : filepath .Base (treePath ),
122- Path : treePath ,
123- SHA : "103ff9234cefeee5ec5361d22b49fbb04d385885" ,
124- LastCommitSHA : lastCommitSHA ,
125- Type : "file" ,
126- Size : 18 ,
127- Encoding : & encoding ,
128- Content : & content ,
129- URL : & selfURL ,
130- HTMLURL : & htmlURL ,
131- GitURL : & gitURL ,
132- DownloadURL : & downloadURL ,
121+ Name : filepath .Base (treePath ),
122+ Path : treePath ,
123+ SHA : "103ff9234cefeee5ec5361d22b49fbb04d385885" ,
124+ LastCommitSHA : lastCommitSHA ,
125+ LastCommitWhen : lastCommitWhen ,
126+ Type : "file" ,
127+ Size : 18 ,
128+ Encoding : & encoding ,
129+ Content : & content ,
130+ URL : & selfURL ,
131+ HTMLURL : & htmlURL ,
132+ GitURL : & gitURL ,
133+ DownloadURL : & downloadURL ,
133134 Links : & api.FileLinksResponse {
134135 Self : & selfURL ,
135136 GitURL : & gitURL ,
@@ -177,7 +178,7 @@ func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *
177178 }
178179}
179180
180- func getExpectedFileResponseForRepofilesUpdate (commitID , filename , lastCommitSHA string ) * api.FileResponse {
181+ func getExpectedFileResponseForRepofilesUpdate (commitID , filename , lastCommitSHA string , lastCommitWhen time. Time ) * api.FileResponse {
181182 encoding := "base64"
182183 content := "VGhpcyBpcyBVUERBVEVEIGNvbnRlbnQgZm9yIHRoZSBSRUFETUUgZmlsZQ=="
183184 selfURL := setting .AppURL + "api/v1/repos/user2/repo1/contents/" + filename + "?ref=master"
@@ -186,18 +187,19 @@ func getExpectedFileResponseForRepofilesUpdate(commitID, filename, lastCommitSHA
186187 downloadURL := setting .AppURL + "user2/repo1/raw/branch/master/" + filename
187188 return & api.FileResponse {
188189 Content : & api.ContentsResponse {
189- Name : filename ,
190- Path : filename ,
191- SHA : "dbf8d00e022e05b7e5cf7e535de857de57925647" ,
192- LastCommitSHA : lastCommitSHA ,
193- Type : "file" ,
194- Size : 43 ,
195- Encoding : & encoding ,
196- Content : & content ,
197- URL : & selfURL ,
198- HTMLURL : & htmlURL ,
199- GitURL : & gitURL ,
200- DownloadURL : & downloadURL ,
190+ Name : filename ,
191+ Path : filename ,
192+ SHA : "dbf8d00e022e05b7e5cf7e535de857de57925647" ,
193+ LastCommitSHA : lastCommitSHA ,
194+ LastCommitWhen : lastCommitWhen ,
195+ Type : "file" ,
196+ Size : 43 ,
197+ Encoding : & encoding ,
198+ Content : & content ,
199+ URL : & selfURL ,
200+ HTMLURL : & htmlURL ,
201+ GitURL : & gitURL ,
202+ DownloadURL : & downloadURL ,
201203 Links : & api.FileLinksResponse {
202204 Self : & selfURL ,
203205 GitURL : & gitURL ,
@@ -264,7 +266,7 @@ func TestChangeRepoFiles(t *testing.T) {
264266 require .NoError (t , err )
265267 lastCommit , err := gitRepo .GetCommitByPath ("new/file.txt" )
266268 require .NoError (t , err )
267- expectedFileResponse := getExpectedFileResponseForRepofilesCreate (commitID , lastCommit .ID .String ())
269+ expectedFileResponse := getExpectedFileResponseForRepofilesCreate (commitID , lastCommit .ID .String (), lastCommit . Committer . When )
268270 assert .Equal (t , expectedFileResponse .Content , filesResponse .Files [0 ])
269271 assert .Equal (t , expectedFileResponse .Commit .SHA , filesResponse .Commit .SHA )
270272 assert .Equal (t , expectedFileResponse .Commit .HTMLURL , filesResponse .Commit .HTMLURL )
@@ -282,7 +284,7 @@ func TestChangeRepoFiles(t *testing.T) {
282284 require .NoError (t , err )
283285 lastCommit , err := commit .GetCommitByPath (opts .Files [0 ].TreePath )
284286 require .NoError (t , err )
285- expectedFileResponse := getExpectedFileResponseForRepofilesUpdate (commit .ID .String (), opts .Files [0 ].TreePath , lastCommit .ID .String ())
287+ expectedFileResponse := getExpectedFileResponseForRepofilesUpdate (commit .ID .String (), opts .Files [0 ].TreePath , lastCommit .ID .String (), lastCommit . Committer . When )
286288 assert .Equal (t , expectedFileResponse .Content , filesResponse .Files [0 ])
287289 assert .Equal (t , expectedFileResponse .Commit .SHA , filesResponse .Commit .SHA )
288290 assert .Equal (t , expectedFileResponse .Commit .HTMLURL , filesResponse .Commit .HTMLURL )
@@ -303,7 +305,7 @@ func TestChangeRepoFiles(t *testing.T) {
303305 require .NoError (t , err )
304306 lastCommit , err := commit .GetCommitByPath (opts .Files [0 ].TreePath )
305307 require .NoError (t , err )
306- expectedFileResponse := getExpectedFileResponseForRepofilesUpdate (commit .ID .String (), opts .Files [0 ].TreePath , lastCommit .ID .String ())
308+ expectedFileResponse := getExpectedFileResponseForRepofilesUpdate (commit .ID .String (), opts .Files [0 ].TreePath , lastCommit .ID .String (), lastCommit . Committer . When )
307309
308310 // assert that the old file no longer exists in the last commit of the branch
309311 fromEntry , err := commit .GetTreeEntryByPath (opts .Files [0 ].FromTreePath )
@@ -339,7 +341,7 @@ func TestChangeRepoFiles(t *testing.T) {
339341
340342 commit , _ := gitRepo .GetBranchCommit (repo .DefaultBranch )
341343 lastCommit , _ := commit .GetCommitByPath (opts .Files [0 ].TreePath )
342- expectedFileResponse := getExpectedFileResponseForRepofilesUpdate (commit .ID .String (), opts .Files [0 ].TreePath , lastCommit .ID .String ())
344+ expectedFileResponse := getExpectedFileResponseForRepofilesUpdate (commit .ID .String (), opts .Files [0 ].TreePath , lastCommit .ID .String (), lastCommit . Committer . When )
343345 assert .Equal (t , expectedFileResponse .Content , filesResponse .Files [0 ])
344346 })
345347
0 commit comments