Skip to content

Commit 3796906

Browse files
committed
fix tests from rename
1 parent 3cf224c commit 3796906

File tree

1 file changed

+49
-125
lines changed

1 file changed

+49
-125
lines changed

pkg/github/actions_test.go

Lines changed: 49 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,6 @@ func Test_CancelWorkflowRun(t *testing.T) {
415415
}
416416

417417
func Test_ListWorkflowRunArtifacts(t *testing.T) {
418-
// Verify tool definition once
419-
mockClient := github.NewClient(nil)
420-
tool, _ := ListWorkflowRunArtifacts(stubGetClientFn(mockClient), translations.NullTranslationHelper)
421-
422-
assert.Equal(t, "list_workflow_run_artifacts", tool.Name)
423-
assert.NotEmpty(t, tool.Description)
424-
assert.Contains(t, tool.InputSchema.Properties, "owner")
425-
assert.Contains(t, tool.InputSchema.Properties, "repo")
426-
assert.Contains(t, tool.InputSchema.Properties, "run_id")
427-
assert.Contains(t, tool.InputSchema.Properties, "perPage")
428-
assert.Contains(t, tool.InputSchema.Properties, "page")
429-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "run_id"})
430-
431418
tests := []struct {
432419
name string
433420
mockedClient *http.Client
@@ -490,29 +477,31 @@ func Test_ListWorkflowRunArtifacts(t *testing.T) {
490477
),
491478
),
492479
requestArgs: map[string]any{
493-
"owner": "owner",
494-
"repo": "repo",
495-
"run_id": float64(12345),
480+
"action": "list_workflow_artifacts",
481+
"owner": "owner",
482+
"repo": "repo",
483+
"resource_id": float64(12345),
496484
},
497485
expectError: false,
498486
},
499487
{
500-
name: "missing required parameter run_id",
488+
name: "missing required parameter resource_id",
501489
mockedClient: mock.NewMockedHTTPClient(),
502490
requestArgs: map[string]any{
503-
"owner": "owner",
504-
"repo": "repo",
491+
"action": "list_workflow_artifacts",
492+
"owner": "owner",
493+
"repo": "repo",
505494
},
506495
expectError: true,
507-
expectedErrMsg: "missing required parameter: run_id",
496+
expectedErrMsg: "missing required parameter: resource_id",
508497
},
509498
}
510499

511500
for _, tc := range tests {
512501
t.Run(tc.name, func(t *testing.T) {
513502
// Setup client with mock
514503
client := github.NewClient(tc.mockedClient)
515-
_, handler := ListWorkflowRunArtifacts(stubGetClientFn(client), translations.NullTranslationHelper)
504+
_, handler := ActionsRead(stubGetClientFn(client), translations.NullTranslationHelper)
516505

517506
// Create call request
518507
request := createMCPRequest(tc.requestArgs)
@@ -543,17 +532,6 @@ func Test_ListWorkflowRunArtifacts(t *testing.T) {
543532
}
544533

545534
func Test_DownloadWorkflowRunArtifact(t *testing.T) {
546-
// Verify tool definition once
547-
mockClient := github.NewClient(nil)
548-
tool, _ := DownloadWorkflowRunArtifact(stubGetClientFn(mockClient), translations.NullTranslationHelper)
549-
550-
assert.Equal(t, "download_workflow_run_artifact", tool.Name)
551-
assert.NotEmpty(t, tool.Description)
552-
assert.Contains(t, tool.InputSchema.Properties, "owner")
553-
assert.Contains(t, tool.InputSchema.Properties, "repo")
554-
assert.Contains(t, tool.InputSchema.Properties, "artifact_id")
555-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "artifact_id"})
556-
557535
tests := []struct {
558536
name string
559537
mockedClient *http.Client
@@ -577,29 +555,31 @@ func Test_DownloadWorkflowRunArtifact(t *testing.T) {
577555
),
578556
),
579557
requestArgs: map[string]any{
558+
"action": "download_workflow_artifact",
580559
"owner": "owner",
581560
"repo": "repo",
582-
"artifact_id": float64(123),
561+
"resource_id": float64(123),
583562
},
584563
expectError: false,
585564
},
586565
{
587-
name: "missing required parameter artifact_id",
566+
name: "missing required parameter resource_id",
588567
mockedClient: mock.NewMockedHTTPClient(),
589568
requestArgs: map[string]any{
590-
"owner": "owner",
591-
"repo": "repo",
569+
"action": "download_workflow_artifact",
570+
"owner": "owner",
571+
"repo": "repo",
592572
},
593573
expectError: true,
594-
expectedErrMsg: "missing required parameter: artifact_id",
574+
expectedErrMsg: "missing required parameter: resource_id",
595575
},
596576
}
597577

598578
for _, tc := range tests {
599579
t.Run(tc.name, func(t *testing.T) {
600580
// Setup client with mock
601581
client := github.NewClient(tc.mockedClient)
602-
_, handler := DownloadWorkflowRunArtifact(stubGetClientFn(client), translations.NullTranslationHelper)
582+
_, handler := ActionsRead(stubGetClientFn(client), translations.NullTranslationHelper)
603583

604584
// Create call request
605585
request := createMCPRequest(tc.requestArgs)
@@ -631,17 +611,6 @@ func Test_DownloadWorkflowRunArtifact(t *testing.T) {
631611
}
632612

633613
func Test_DeleteWorkflowRunLogs(t *testing.T) {
634-
// Verify tool definition once
635-
mockClient := github.NewClient(nil)
636-
tool, _ := DeleteWorkflowRunLogs(stubGetClientFn(mockClient), translations.NullTranslationHelper)
637-
638-
assert.Equal(t, "delete_workflow_run_logs", tool.Name)
639-
assert.NotEmpty(t, tool.Description)
640-
assert.Contains(t, tool.InputSchema.Properties, "owner")
641-
assert.Contains(t, tool.InputSchema.Properties, "repo")
642-
assert.Contains(t, tool.InputSchema.Properties, "run_id")
643-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "run_id"})
644-
645614
tests := []struct {
646615
name string
647616
mockedClient *http.Client
@@ -712,17 +681,6 @@ func Test_DeleteWorkflowRunLogs(t *testing.T) {
712681
}
713682

714683
func Test_GetWorkflowRunUsage(t *testing.T) {
715-
// Verify tool definition once
716-
mockClient := github.NewClient(nil)
717-
tool, _ := GetWorkflowRunUsage(stubGetClientFn(mockClient), translations.NullTranslationHelper)
718-
719-
assert.Equal(t, "get_workflow_run_usage", tool.Name)
720-
assert.NotEmpty(t, tool.Description)
721-
assert.Contains(t, tool.InputSchema.Properties, "owner")
722-
assert.Contains(t, tool.InputSchema.Properties, "repo")
723-
assert.Contains(t, tool.InputSchema.Properties, "run_id")
724-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "run_id"})
725-
726684
tests := []struct {
727685
name string
728686
mockedClient *http.Client
@@ -761,29 +719,31 @@ func Test_GetWorkflowRunUsage(t *testing.T) {
761719
),
762720
),
763721
requestArgs: map[string]any{
764-
"owner": "owner",
765-
"repo": "repo",
766-
"run_id": float64(12345),
722+
"action": "get_workflow_run_usage",
723+
"owner": "owner",
724+
"repo": "repo",
725+
"resource_id": float64(12345),
767726
},
768727
expectError: false,
769728
},
770729
{
771730
name: "missing required parameter run_id",
772731
mockedClient: mock.NewMockedHTTPClient(),
773732
requestArgs: map[string]any{
774-
"owner": "owner",
775-
"repo": "repo",
733+
"action": "get_workflow_run_usage",
734+
"owner": "owner",
735+
"repo": "repo",
776736
},
777737
expectError: true,
778-
expectedErrMsg: "missing required parameter: run_id",
738+
expectedErrMsg: "missing required parameter: resource_id",
779739
},
780740
}
781741

782742
for _, tc := range tests {
783743
t.Run(tc.name, func(t *testing.T) {
784744
// Setup client with mock
785745
client := github.NewClient(tc.mockedClient)
786-
_, handler := GetWorkflowRunUsage(stubGetClientFn(client), translations.NullTranslationHelper)
746+
_, handler := ActionsRead(stubGetClientFn(client), translations.NullTranslationHelper)
787747

788748
// Create call request
789749
request := createMCPRequest(tc.requestArgs)
@@ -1328,11 +1288,11 @@ func Test_ActionsResourceRead(t *testing.T) {
13281288

13291289
assert.Equal(t, "actions_resource_read", tool.Name)
13301290
assert.NotEmpty(t, tool.Description)
1331-
assert.Contains(t, tool.InputSchema.Properties, "resource")
1291+
assert.Contains(t, tool.InputSchema.Properties, "action")
13321292
assert.Contains(t, tool.InputSchema.Properties, "owner")
13331293
assert.Contains(t, tool.InputSchema.Properties, "repo")
13341294
assert.Contains(t, tool.InputSchema.Properties, "resource_id")
1335-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"resource", "owner", "repo", "resource_id"})
1295+
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"action", "owner", "repo", "resource_id"})
13361296

13371297
tests := []struct {
13381298
name string
@@ -1342,21 +1302,21 @@ func Test_ActionsResourceRead(t *testing.T) {
13421302
expectedErrMsg string
13431303
}{
13441304
{
1345-
name: "missing required parameter resource",
1305+
name: "missing required parameter action",
13461306
mockedClient: mock.NewMockedHTTPClient(),
13471307
requestArgs: map[string]any{
13481308
"owner": "owner",
13491309
"repo": "repo",
13501310
"resource_id": float64(123),
13511311
},
13521312
expectError: true,
1353-
expectedErrMsg: "missing required parameter: resource",
1313+
expectedErrMsg: "missing required parameter: action",
13541314
},
13551315
{
13561316
name: "missing required parameter owner",
13571317
mockedClient: mock.NewMockedHTTPClient(),
13581318
requestArgs: map[string]any{
1359-
"resource": "workflow",
1319+
"action": "get_workflow",
13601320
"repo": "repo",
13611321
"resource_id": float64(123),
13621322
},
@@ -1367,7 +1327,7 @@ func Test_ActionsResourceRead(t *testing.T) {
13671327
name: "missing required parameter repo",
13681328
mockedClient: mock.NewMockedHTTPClient(),
13691329
requestArgs: map[string]any{
1370-
"resource": "workflow",
1330+
"action": "get_workflow",
13711331
"owner": "owner",
13721332
"resource_id": float64(123),
13731333
},
@@ -1378,9 +1338,9 @@ func Test_ActionsResourceRead(t *testing.T) {
13781338
name: "missing required parameter resource_id",
13791339
mockedClient: mock.NewMockedHTTPClient(),
13801340
requestArgs: map[string]any{
1381-
"owner": "owner",
1382-
"repo": "repo",
1383-
"resource": "workflow",
1341+
"action": "get_workflow",
1342+
"owner": "owner",
1343+
"repo": "repo",
13841344
},
13851345
expectError: true,
13861346
expectedErrMsg: "missing required parameter: resource_id",
@@ -1389,13 +1349,13 @@ func Test_ActionsResourceRead(t *testing.T) {
13891349
name: "unknown resource",
13901350
mockedClient: mock.NewMockedHTTPClient(),
13911351
requestArgs: map[string]any{
1392-
"resource": "random",
1352+
"action": "random",
13931353
"owner": "owner",
13941354
"repo": "repo",
13951355
"resource_id": float64(123),
13961356
},
13971357
expectError: true,
1398-
expectedErrMsg: "unknown resource type: random",
1358+
expectedErrMsg: "unknown action: random",
13991359
},
14001360
}
14011361

@@ -1425,19 +1385,7 @@ func Test_ActionsResourceRead(t *testing.T) {
14251385
}
14261386
}
14271387

1428-
func Test_ActionsResourceRead_Workflow(t *testing.T) {
1429-
// Verify tool definition once
1430-
mockClient := github.NewClient(nil)
1431-
tool, _ := ActionsRead(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1432-
1433-
assert.Equal(t, "actions_resource_read", tool.Name)
1434-
assert.NotEmpty(t, tool.Description)
1435-
assert.Contains(t, tool.InputSchema.Properties, "resource")
1436-
assert.Contains(t, tool.InputSchema.Properties, "owner")
1437-
assert.Contains(t, tool.InputSchema.Properties, "repo")
1438-
assert.Contains(t, tool.InputSchema.Properties, "resource_id")
1439-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"resource", "owner", "repo", "resource_id"})
1440-
1388+
func Test_ActionsResourceRead_GetWorkflow(t *testing.T) {
14411389
tests := []struct {
14421390
name string
14431391
mockedClient *http.Client
@@ -1465,7 +1413,7 @@ func Test_ActionsResourceRead_Workflow(t *testing.T) {
14651413
),
14661414
),
14671415
requestArgs: map[string]any{
1468-
"resource": "workflow",
1416+
"action": "get_workflow",
14691417
"owner": "owner",
14701418
"repo": "repo",
14711419
"resource_id": float64(1),
@@ -1483,7 +1431,7 @@ func Test_ActionsResourceRead_Workflow(t *testing.T) {
14831431
),
14841432
),
14851433
requestArgs: map[string]any{
1486-
"resource": "workflow",
1434+
"action": "get_workflow",
14871435
"owner": "owner",
14881436
"repo": "repo",
14891437
"resource_id": float64(2),
@@ -1532,19 +1480,7 @@ func Test_ActionsResourceRead_Workflow(t *testing.T) {
15321480
}
15331481
}
15341482

1535-
func Test_ActionsResourceRead_WorkflowRun(t *testing.T) {
1536-
// Verify tool definition once
1537-
mockClient := github.NewClient(nil)
1538-
tool, _ := ActionsRead(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1539-
1540-
assert.Equal(t, "actions_resource_read", tool.Name)
1541-
assert.NotEmpty(t, tool.Description)
1542-
assert.Contains(t, tool.InputSchema.Properties, "resource")
1543-
assert.Contains(t, tool.InputSchema.Properties, "owner")
1544-
assert.Contains(t, tool.InputSchema.Properties, "repo")
1545-
assert.Contains(t, tool.InputSchema.Properties, "resource_id")
1546-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"resource", "owner", "repo", "resource_id"})
1547-
1483+
func Test_ActionsResourceRead_GetWorkflowRun(t *testing.T) {
15481484
tests := []struct {
15491485
name string
15501486
mockedClient *http.Client
@@ -1572,7 +1508,7 @@ func Test_ActionsResourceRead_WorkflowRun(t *testing.T) {
15721508
),
15731509
),
15741510
requestArgs: map[string]any{
1575-
"resource": "workflow_run",
1511+
"action": "get_workflow_run",
15761512
"owner": "owner",
15771513
"repo": "repo",
15781514
"resource_id": float64(12345),
@@ -1590,7 +1526,7 @@ func Test_ActionsResourceRead_WorkflowRun(t *testing.T) {
15901526
),
15911527
),
15921528
requestArgs: map[string]any{
1593-
"resource": "workflow_run",
1529+
"action": "get_workflow_run",
15941530
"owner": "owner",
15951531
"repo": "repo",
15961532
"resource_id": float64(99999),
@@ -1641,19 +1577,7 @@ func Test_ActionsResourceRead_WorkflowRun(t *testing.T) {
16411577
}
16421578
}
16431579

1644-
func Test_ActionsResourceRead_WorkflowRuns(t *testing.T) {
1645-
// Verify tool definition once
1646-
mockClient := github.NewClient(nil)
1647-
tool, _ := ActionsRead(stubGetClientFn(mockClient), translations.NullTranslationHelper)
1648-
1649-
assert.Equal(t, "actions_resource_read", tool.Name)
1650-
assert.NotEmpty(t, tool.Description)
1651-
assert.Contains(t, tool.InputSchema.Properties, "resource")
1652-
assert.Contains(t, tool.InputSchema.Properties, "owner")
1653-
assert.Contains(t, tool.InputSchema.Properties, "repo")
1654-
assert.Contains(t, tool.InputSchema.Properties, "resource_id")
1655-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"resource", "owner", "repo", "resource_id"})
1656-
1580+
func Test_ActionsResourceRead_ListWorkflowRuns(t *testing.T) {
16571581
tests := []struct {
16581582
name string
16591583
mockedClient *http.Client
@@ -1693,7 +1617,7 @@ func Test_ActionsResourceRead_WorkflowRuns(t *testing.T) {
16931617
),
16941618
),
16951619
requestArgs: map[string]any{
1696-
"resource": "workflow_runs",
1620+
"action": "list_workflow_runs",
16971621
"owner": "owner",
16981622
"repo": "repo",
16991623
"resource_id": float64(1),
@@ -1732,11 +1656,11 @@ func Test_ActionsResourceRead_WorkflowRuns(t *testing.T) {
17321656
),
17331657
),
17341658
requestArgs: map[string]any{
1735-
"resource": "workflow_runs",
1659+
"action": "list_workflow_runs",
17361660
"owner": "owner",
17371661
"repo": "repo",
17381662
"resource_id": float64(1),
1739-
"workflow_runs_filter": map[string]string{
1663+
"workflow_runs_filter": map[string]any{
17401664
"actor": "omgitsads",
17411665
"status": "completed",
17421666
},
@@ -1754,7 +1678,7 @@ func Test_ActionsResourceRead_WorkflowRuns(t *testing.T) {
17541678
),
17551679
),
17561680
requestArgs: map[string]any{
1757-
"resource": "workflow_runs",
1681+
"action": "list_workflow_runs",
17581682
"owner": "owner",
17591683
"repo": "repo",
17601684
"resource_id": float64(99999),

0 commit comments

Comments
 (0)