@@ -113,6 +113,7 @@ func TestGithubProviderCreateStatus(t *testing.T) {
113113 detailsURL string
114114 titleSubstr string
115115 nilCompletedAtDate bool
116+ githubApps bool
116117 }
117118 tests := []struct {
118119 name string
@@ -130,6 +131,21 @@ func TestGithubProviderCreateStatus(t *testing.T) {
130131 text : "Yay" ,
131132 detailsURL : "https://cireport.com" ,
132133 titleSubstr : "Success" ,
134+ githubApps : true ,
135+ },
136+ want : & github.CheckRun {ID : & resultid },
137+ wantErr : false ,
138+ },
139+ {
140+ name : "success coming from webhook" ,
141+ args : args {
142+ runevent : runEvent ,
143+ status : "completed" ,
144+ conclusion : "success" ,
145+ text : "Yay" ,
146+ detailsURL : "https://cireport.com" ,
147+ titleSubstr : "Success" ,
148+ githubApps : false ,
133149 },
134150 want : & github.CheckRun {ID : & resultid },
135151 wantErr : false ,
@@ -143,6 +159,7 @@ func TestGithubProviderCreateStatus(t *testing.T) {
143159 text : "Yay" ,
144160 detailsURL : "https://cireport.com" ,
145161 nilCompletedAtDate : true ,
162+ githubApps : true ,
146163 },
147164 want : & github.CheckRun {ID : & resultid },
148165 wantErr : false ,
@@ -156,6 +173,7 @@ func TestGithubProviderCreateStatus(t *testing.T) {
156173 text : "Nay" ,
157174 detailsURL : "https://cireport.com" ,
158175 titleSubstr : "Failed" ,
176+ githubApps : true ,
159177 },
160178 want : & github.CheckRun {ID : & resultid },
161179 wantErr : false ,
@@ -169,6 +187,7 @@ func TestGithubProviderCreateStatus(t *testing.T) {
169187 text : "Skipit" ,
170188 detailsURL : "https://cireport.com" ,
171189 titleSubstr : "Skipped" ,
190+ githubApps : true ,
172191 },
173192 want : & github.CheckRun {ID : & resultid },
174193 wantErr : false ,
@@ -182,6 +201,7 @@ func TestGithubProviderCreateStatus(t *testing.T) {
182201 text : "Je sais pas ce qui se passe wesh" ,
183202 detailsURL : "https://cireport.com" ,
184203 titleSubstr : "Unknown" ,
204+ githubApps : true ,
185205 },
186206 want : & github.CheckRun {ID : & resultid },
187207 wantErr : false ,
@@ -201,6 +221,7 @@ func TestGithubProviderCreateStatus(t *testing.T) {
201221 gcvs := Provider {
202222 Client : fakeclient ,
203223 }
224+ mux .HandleFunc ("/repos/check/run/statuses/sha" , func (rw http.ResponseWriter , r * http.Request ) {})
204225 mux .HandleFunc (fmt .Sprintf ("/repos/check/run/check-runs/%d" , checkrunid ), func (rw http.ResponseWriter , r * http.Request ) {
205226 bit , _ := ioutil .ReadAll (r .Body )
206227 checkRun := & github.CheckRun {}
@@ -232,13 +253,18 @@ func TestGithubProviderCreateStatus(t *testing.T) {
232253 pacopts := & info.PacOpts {
233254 LogURL : "https://log" ,
234255 }
235- if ! tt .notoken {
256+ if tt .notoken {
257+ tt .args .runevent = info .NewEvent ()
258+ } else {
236259 tt .args .runevent .Provider = & info.Provider {
237260 Token : "hello" ,
238261 URL : "moto" ,
239262 }
240- } else {
241- tt .args .runevent = info .NewEvent ()
263+ if tt .args .githubApps {
264+ tt .args .runevent .InstallationID = 12345
265+ } else {
266+ tt .args .runevent .SHA = "sha"
267+ }
242268 }
243269 err := gcvs .CreateStatus (ctx , nil , tt .args .runevent , pacopts , status )
244270 if (err != nil ) != tt .wantErr {
0 commit comments