@@ -438,6 +438,15 @@ func TestGetFailedJobURLs(t *testing.T) {
438438 ]}` ,
439439 expected : map [string ]string {},
440440 },
441+ {
442+ name : "timed_out jobs are excluded" ,
443+ runID : 123 ,
444+ mockResponse : `{"jobs": [
445+ {"id": 1, "name": "Failed Job", "conclusion": "failure", "html_url": "http://job/1"},
446+ {"id": 2, "name": "Timed out Job", "conclusion": "timed_out", "html_url": "http://job/2"}
447+ ]}` ,
448+ expected : map [string ]string {"Failed Job" : "http://job/1" },
449+ },
441450 }
442451
443452 for _ , tt := range tests {
@@ -458,7 +467,6 @@ func TestGetFailedJobURLs(t *testing.T) {
458467 },
459468 }
460469
461- // Override client base URL to point to mock server
462470 c , _ := github .NewClient (nil ).WithEnterpriseURLs (server .URL , server .URL )
463471 client .client = c
464472
@@ -472,3 +480,45 @@ func TestGetFailedJobURLs(t *testing.T) {
472480 })
473481 }
474482}
483+
484+ func TestMultiJobTemplateExpansion (t * testing.T ) {
485+ envVariables := map [string ]string {
486+ githubWorkflow : "test-ci" ,
487+ githubServerURL : "https://github.com" ,
488+ githubOwner : "test-org" ,
489+ githubRepository : "test-repo" ,
490+ githubRunID : "555555" ,
491+ githubSHAKey : "abcde12345" ,
492+ }
493+
494+ report := report.Report {
495+ Module : "test-module" ,
496+ }
497+
498+ t .Run ("single failed job link" , func (t * testing.T ) {
499+ mockResponse := & github.Jobs {Jobs : []* github.WorkflowJob {
500+ {Name : github .Ptr ("Job A" ), Conclusion : github .Ptr ("failure" ), HTMLURL : github .Ptr ("http://job/a" )},
501+ }}
502+ mockedHTTPClient := newMockHTTPClient (t , mock .GetReposActionsRunsJobsByOwnerByRepoByRunId , mockResponse , 0 )
503+ client := newTestClient (t , mockedHTTPClient )
504+ client .envVariables = envVariables
505+
506+ expand := templateHelper (context .Background (), client , envVariables , report , 0 )
507+ result := expand ("linkToBuild" )
508+
509+ assert .Equal (t , "http://job/a" , result )
510+ })
511+
512+ t .Run ("multiple failed jobs list" , func (t * testing.T ) {
513+ mockResponse := & github.Jobs {Jobs : []* github.WorkflowJob {
514+ {Name : github .Ptr ("Job A" ), Conclusion : github .Ptr ("failure" ), HTMLURL : github .Ptr ("http://job/a" )},
515+ {Name : github .Ptr ("Job B" ), Conclusion : github .Ptr ("failure" ), HTMLURL : github .Ptr ("http://job/b" )},
516+ }}
517+ mockedHTTPClient := newMockHTTPClient (t , mock .GetReposActionsRunsJobsByOwnerByRepoByRunId , mockResponse , 0 )
518+ client := newTestClient (t , mockedHTTPClient )
519+ client .envVariables = envVariables
520+
521+ expand := templateHelper (context .Background (), client , envVariables , report , 0 )
522+ assert .Equal (t , "\n - [`Job A`](http://job/a)\n - [`Job B`](http://job/b)" , expand ("linkToBuild" ))
523+ })
524+ }
0 commit comments