@@ -323,12 +323,14 @@ func Test_CancelWorkflowRun(t *testing.T) {
323
323
{
324
324
name :"successful workflow run cancellation" ,
325
325
mockedClient :mock .NewMockedHTTPClient (
326
- mock .WithRequestMatch (
326
+ mock .WithRequestMatchHandler (
327
327
mock.EndpointPattern {
328
328
Pattern :"/repos/owner/repo/actions/runs/12345/cancel" ,
329
329
Method :"POST" ,
330
330
},
331
- "" ,// Empty response body for 202 Accepted
331
+ http .HandlerFunc (func (w http.ResponseWriter ,_ * http.Request ) {
332
+ w .WriteHeader (http .StatusAccepted )
333
+ }),
332
334
),
333
335
),
334
336
requestArgs :map [string ]any {
@@ -338,6 +340,27 @@ func Test_CancelWorkflowRun(t *testing.T) {
338
340
},
339
341
expectError :false ,
340
342
},
343
+ {
344
+ name :"conflict when cancelling a workflow run" ,
345
+ mockedClient :mock .NewMockedHTTPClient (
346
+ mock .WithRequestMatchHandler (
347
+ mock.EndpointPattern {
348
+ Pattern :"/repos/owner/repo/actions/runs/12345/cancel" ,
349
+ Method :"POST" ,
350
+ },
351
+ http .HandlerFunc (func (w http.ResponseWriter ,_ * http.Request ) {
352
+ w .WriteHeader (http .StatusConflict )
353
+ }),
354
+ ),
355
+ ),
356
+ requestArgs :map [string ]any {
357
+ "owner" :"owner" ,
358
+ "repo" :"repo" ,
359
+ "run_id" :float64 (12345 ),
360
+ },
361
+ expectError :true ,
362
+ expectedErrMsg :"failed to cancel workflow run" ,
363
+ },
341
364
{
342
365
name :"missing required parameter run_id" ,
343
366
mockedClient :mock .NewMockedHTTPClient (),
@@ -369,7 +392,7 @@ func Test_CancelWorkflowRun(t *testing.T) {
369
392
textContent := getTextResult (t ,result )
370
393
371
394
if tc .expectedErrMsg != "" {
372
- assert .Equal (t ,tc . expectedErrMsg , textContent . Text )
395
+ assert .Contains (t ,textContent . Text , tc . expectedErrMsg )
373
396
return
374
397
}
375
398