Skip to content

Commit 51b7a40

Browse files
committed
fix the tests that Copilot removed!
1 parent cb72434 commit 51b7a40

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

pkg/github/notifications_test.go

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/github/github-mcp-server/internal/toolsnaps"
1010
"github.com/github/github-mcp-server/pkg/translations"
1111
"github.com/google/go-github/v79/github"
12+
"github.com/google/jsonschema-go/jsonschema"
1213
"github.com/migueleliasweb/go-github-mock/src/mock"
1314
"github.com/stretchr/testify/assert"
1415
"github.com/stretchr/testify/require"
@@ -22,8 +23,18 @@ func Test_ListNotifications(t *testing.T) {
2223

2324
assert.Equal(t, "list_notifications", tool.Name)
2425
assert.NotEmpty(t, tool.Description)
25-
// All fields are optional, so Required should be empty (note: InputSchema.Required is []string, not an assertion property)
2626

27+
schema, ok := tool.InputSchema.(*jsonschema.Schema)
28+
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
29+
assert.Contains(t, schema.Properties, "filter")
30+
assert.Contains(t, schema.Properties, "since")
31+
assert.Contains(t, schema.Properties, "before")
32+
assert.Contains(t, schema.Properties, "owner")
33+
assert.Contains(t, schema.Properties, "repo")
34+
assert.Contains(t, schema.Properties, "page")
35+
assert.Contains(t, schema.Properties, "perPage")
36+
// All fields are optional, so Required should be empty
37+
assert.Empty(t, schema.Required)
2738
mockNotification := &github.Notification{
2839
ID: github.Ptr("123"),
2940
Reason: github.Ptr("mention"),
@@ -150,6 +161,12 @@ func Test_ManageNotificationSubscription(t *testing.T) {
150161
assert.Equal(t, "manage_notification_subscription", tool.Name)
151162
assert.NotEmpty(t, tool.Description)
152163

164+
schema, ok := tool.InputSchema.(*jsonschema.Schema)
165+
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
166+
assert.Contains(t, schema.Properties, "notificationID")
167+
assert.Contains(t, schema.Properties, "action")
168+
assert.Equal(t, []string{"notificationID", "action"}, schema.Required)
169+
153170
mockSub := &github.Subscription{Ignored: github.Ptr(true)}
154171
mockSubWatch := &github.Subscription{Ignored: github.Ptr(false), Subscribed: github.Ptr(true)}
155172

@@ -285,6 +302,13 @@ func Test_ManageRepositoryNotificationSubscription(t *testing.T) {
285302
assert.Equal(t, "manage_repository_notification_subscription", tool.Name)
286303
assert.NotEmpty(t, tool.Description)
287304

305+
schema, ok := tool.InputSchema.(*jsonschema.Schema)
306+
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
307+
assert.Contains(t, schema.Properties, "owner")
308+
assert.Contains(t, schema.Properties, "repo")
309+
assert.Contains(t, schema.Properties, "action")
310+
assert.Equal(t, []string{"owner", "repo", "action"}, schema.Required)
311+
288312
mockSub := &github.Subscription{Ignored: github.Ptr(true)}
289313
mockWatchSub := &github.Subscription{Ignored: github.Ptr(false), Subscribed: github.Ptr(true)}
290314

@@ -444,6 +468,12 @@ func Test_DismissNotification(t *testing.T) {
444468
assert.Equal(t, "dismiss_notification", tool.Name)
445469
assert.NotEmpty(t, tool.Description)
446470

471+
schema, ok := tool.InputSchema.(*jsonschema.Schema)
472+
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
473+
assert.Contains(t, schema.Properties, "threadID")
474+
assert.Contains(t, schema.Properties, "state")
475+
assert.Equal(t, []string{"threadID", "state"}, schema.Required)
476+
447477
tests := []struct {
448478
name string
449479
mockedClient *http.Client
@@ -573,6 +603,13 @@ func Test_MarkAllNotificationsRead(t *testing.T) {
573603
assert.Equal(t, "mark_all_notifications_read", tool.Name)
574604
assert.NotEmpty(t, tool.Description)
575605

606+
schema, ok := tool.InputSchema.(*jsonschema.Schema)
607+
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
608+
assert.Contains(t, schema.Properties, "lastReadAt")
609+
assert.Contains(t, schema.Properties, "owner")
610+
assert.Contains(t, schema.Properties, "repo")
611+
assert.Empty(t, schema.Required)
612+
576613
tests := []struct {
577614
name string
578615
mockedClient *http.Client
@@ -672,6 +709,11 @@ func Test_GetNotificationDetails(t *testing.T) {
672709
assert.Equal(t, "get_notification_details", tool.Name)
673710
assert.NotEmpty(t, tool.Description)
674711

712+
schema, ok := tool.InputSchema.(*jsonschema.Schema)
713+
require.True(t, ok, "InputSchema should be *jsonschema.Schema")
714+
assert.Contains(t, schema.Properties, "notificationID")
715+
assert.Equal(t, []string{"notificationID"}, schema.Required)
716+
675717
mockThread := &github.Notification{ID: github.Ptr("123"), Reason: github.Ptr("mention")}
676718

677719
tests := []struct {

0 commit comments

Comments
 (0)