@@ -200,3 +200,38 @@ func TestActionsService_GetWorkflowRunLogs_StatusMovedPermanently_followRedirect
200200 t .Errorf ("Actions.GetWorkflowJobLogs returned %+v, want %+v" , url .String (), want )
201201 }
202202}
203+
204+ func TestActionService_ListRepositoryWorkflowRuns (t * testing.T ) {
205+ client , mux , _ , teardown := setup ()
206+ defer teardown ()
207+
208+ mux .HandleFunc ("/repos/o/r/actions/runs" , func (w http.ResponseWriter , r * http.Request ) {
209+ testMethod (t , r , "GET" )
210+ testFormValues (t , r , values {"per_page" : "2" , "page" : "2" })
211+ fmt .Fprint (w , `{"total_count":2,
212+ "workflow_runs":[
213+ {"id":298499444,"run_number":301,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"},
214+ {"id":298499445,"run_number":302,"created_at":"2020-04-11T11:14:54Z","updated_at":"2020-04-11T11:14:54Z"}]}` )
215+
216+ })
217+
218+ opts := & ListOptions {Page : 2 , PerPage : 2 }
219+ runs , _ , err := client .Actions .ListRepositoryWorkflowRuns (context .Background (), "o" , "r" , opts )
220+
221+ if err != nil {
222+ t .Errorf ("Actions.ListRepositoryWorkflowRuns returned error: %v" , err )
223+ }
224+
225+ expected := & WorkflowRuns {
226+ TotalCount : Int (2 ),
227+ WorkflowRuns : []* WorkflowRun {
228+ {ID : Int64 (298499444 ), RunNumber : Int (301 ), CreatedAt : & Timestamp {time .Date (2020 , time .April , 11 , 11 , 14 , 54 , 0 , time .UTC )}, UpdatedAt : & Timestamp {time .Date (2020 , time .April , 11 , 11 , 14 , 54 , 0 , time .UTC )}},
229+ {ID : Int64 (298499445 ), RunNumber : Int (302 ), CreatedAt : & Timestamp {time .Date (2020 , time .April , 11 , 11 , 14 , 54 , 0 , time .UTC )}, UpdatedAt : & Timestamp {time .Date (2020 , time .April , 11 , 11 , 14 , 54 , 0 , time .UTC )}},
230+ },
231+ }
232+
233+ if ! reflect .DeepEqual (runs , expected ) {
234+ t .Errorf ("Actions.ListRepositoryWorkflowRuns returned %+v, want %+v" , runs , expected )
235+ }
236+
237+ }
0 commit comments