@@ -106,7 +106,7 @@ func getExpectedFileResponseForRepofilesDelete() *api.FileResponse {
106106 }
107107}
108108
109- func getExpectedFileResponseForRepofilesCreate (commitID , lastCommitSHA string ) * api.FileResponse {
109+ func getExpectedFileResponseForRepofilesCreate (commitID string , lastCommit * git. Commit ) * api.FileResponse {
110110 treePath := "new/file.txt"
111111 encoding := "base64"
112112 content := "VGhpcyBpcyBhIE5FVyBmaWxl"
@@ -116,18 +116,19 @@ func getExpectedFileResponseForRepofilesCreate(commitID, lastCommitSHA string) *
116116 downloadURL := setting .AppURL + "user2/repo1/raw/branch/master/" + treePath
117117 return & api.FileResponse {
118118 Content : & api.ContentsResponse {
119- Name : filepath .Base (treePath ),
120- Path : treePath ,
121- SHA : "103ff9234cefeee5ec5361d22b49fbb04d385885" ,
122- LastCommitSHA : lastCommitSHA ,
123- Type : "file" ,
124- Size : 18 ,
125- Encoding : & encoding ,
126- Content : & content ,
127- URL : & selfURL ,
128- HTMLURL : & htmlURL ,
129- GitURL : & gitURL ,
130- DownloadURL : & downloadURL ,
119+ Name : filepath .Base (treePath ),
120+ Path : treePath ,
121+ SHA : "103ff9234cefeee5ec5361d22b49fbb04d385885" ,
122+ LastCommitSHA : lastCommit .ID .String (),
123+ LastCommitWhen : lastCommit .Committer .When ,
124+ Type : "file" ,
125+ Size : 18 ,
126+ Encoding : & encoding ,
127+ Content : & content ,
128+ URL : & selfURL ,
129+ HTMLURL : & htmlURL ,
130+ GitURL : & gitURL ,
131+ DownloadURL : & downloadURL ,
131132 Links : & api.FileLinksResponse {
132133 Self : & selfURL ,
133134 GitURL : & gitURL ,
@@ -269,10 +270,17 @@ func TestChangeRepoFilesForCreate(t *testing.T) {
269270
270271 commitID , _ := gitRepo .GetBranchCommitID (opts .NewBranch )
271272 lastCommit , _ := gitRepo .GetCommitByPath ("new/file.txt" )
272- expectedFileResponse := getExpectedFileResponseForRepofilesCreate (commitID , lastCommit . ID . String () )
273+ expectedFileResponse := getExpectedFileResponseForRepofilesCreate (commitID , lastCommit )
273274 assert .NotNil (t , expectedFileResponse )
274275 if expectedFileResponse != nil {
275- assert .EqualValues (t , expectedFileResponse .Content , filesResponse .Files [0 ])
276+ assert .EqualValues (t , expectedFileResponse .Content .Name , filesResponse .Files [0 ].Name )
277+ assert .EqualValues (t , expectedFileResponse .Content .Path , filesResponse .Files [0 ].Path )
278+ assert .EqualValues (t , expectedFileResponse .Content .SHA , filesResponse .Files [0 ].SHA )
279+ assert .EqualValues (t , expectedFileResponse .Content .LastCommitSHA , filesResponse .Files [0 ].LastCommitSHA )
280+ assert .EqualValues (t , expectedFileResponse .Content .LastCommitWhen , filesResponse .Files [0 ].LastCommitWhen )
281+ assert .EqualValues (t , expectedFileResponse .Content .Type , filesResponse .Files [0 ].Type )
282+ assert .EqualValues (t , expectedFileResponse .Content .Size , filesResponse .Files [0 ].Size )
283+
276284 assert .EqualValues (t , expectedFileResponse .Commit .SHA , filesResponse .Commit .SHA )
277285 assert .EqualValues (t , expectedFileResponse .Commit .HTMLURL , filesResponse .Commit .HTMLURL )
278286 assert .EqualValues (t , expectedFileResponse .Commit .Author .Email , filesResponse .Commit .Author .Email )
0 commit comments