@@ -52,13 +52,22 @@ func generateMockStepsLog(logCur actions.LogCursor) (stepsLog []*actions.ViewSte
5252 return stepsLog
5353}
5454
55+ func MockActionsView (ctx * context.Context ) {
56+ ctx .Data ["RunID" ] = ctx .PathParam ("run" )
57+ ctx .Data ["JobID" ] = ctx .PathParam ("job" )
58+ ctx .HTML (http .StatusOK , "devtest/repo-action-view" )
59+ }
60+
5561func MockActionsRunsJobs (ctx * context.Context ) {
56- req := web . GetForm ( ctx ).( * actions. ViewRequest )
62+ runID := ctx . PathParamInt64 ( "run" )
5763
64+ req := web .GetForm (ctx ).(* actions.ViewRequest )
5865 resp := & actions.ViewResponse {}
5966 resp .State .Run .TitleHTML = `mock run title <a href="/">link</a>`
6067 resp .State .Run .Status = actions_model .StatusRunning .String ()
61- resp .State .Run .CanCancel = true
68+ resp .State .Run .CanCancel = runID == 10
69+ resp .State .Run .CanApprove = runID == 20
70+ resp .State .Run .CanRerun = runID == 30
6271 resp .State .Run .CanDeleteArtifact = true
6372 resp .State .Run .WorkflowID = "workflow-id"
6473 resp .State .Run .WorkflowLink = "./workflow-link"
@@ -85,6 +94,29 @@ func MockActionsRunsJobs(ctx *context.Context) {
8594 Size : 1024 * 1024 ,
8695 Status : "completed" ,
8796 })
97+
98+ resp .State .Run .Jobs = append (resp .State .Run .Jobs , & actions.ViewJob {
99+ ID : runID * 10 ,
100+ Name : "job 100" ,
101+ Status : actions_model .StatusRunning .String (),
102+ CanRerun : true ,
103+ Duration : "1h" ,
104+ })
105+ resp .State .Run .Jobs = append (resp .State .Run .Jobs , & actions.ViewJob {
106+ ID : runID * 10 + 1 ,
107+ Name : "job 101" ,
108+ Status : actions_model .StatusWaiting .String (),
109+ CanRerun : false ,
110+ Duration : "2h" ,
111+ })
112+ resp .State .Run .Jobs = append (resp .State .Run .Jobs , & actions.ViewJob {
113+ ID : runID * 10 + 2 ,
114+ Name : "job 102" ,
115+ Status : actions_model .StatusFailure .String (),
116+ CanRerun : false ,
117+ Duration : "3h" ,
118+ })
119+
88120 resp .State .CurrentJob .Steps = append (resp .State .CurrentJob .Steps , & actions.ViewJobStep {
89121 Summary : "step 0 (mock slow)" ,
90122 Duration : time .Hour .String (),
0 commit comments