Skip to content

Commit c8e270b

Browse files
implement code review feedback
1 parent 19401ff commit c8e270b

File tree

3 files changed

+669
-227
lines changed

3 files changed

+669
-227
lines changed

e2e/e2e_test.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ func TestPullRequestReviewDeletion(t *testing.T) {
15371537
require.Len(t, noReviews, 0, "expected to find no reviews")
15381538
}
15391539

1540-
func TestE2E_ListNotifications(t *testing.T) {
1540+
func ListNotifications(t *testing.T) {
15411541
t.Parallel()
15421542
client := setupMCPClient(t)
15431543
ctx := context.Background()
@@ -1560,7 +1560,7 @@ func TestE2E_ListNotifications(t *testing.T) {
15601560
require.NoError(t, err, "expected to unmarshal text content successfully")
15611561
}
15621562

1563-
func TestE2E_ManageNotificationSubscription(t *testing.T) {
1563+
func ManageNotificationSubscription(t *testing.T) {
15641564
skipIfGlobalMutationNotOptedIn(t)
15651565
t.Parallel()
15661566
client := setupMCPClient(t)
@@ -1645,13 +1645,14 @@ func TestE2E_ManageNotificationSubscription(t *testing.T) {
16451645

16461646
// Validate with REST client
16471647
sub, resp2, err := restClient.Activity.GetThreadSubscription(ctx, notificationID)
1648-
// According to GitHub API, a deleted subscription returns 404
1649-
require.Error(t, err)
1650-
require.Nil(t, sub)
1651-
require.Equal(t, 404, resp2.StatusCode)
1648+
require.NoError(t, err)
1649+
require.NotNil(t, sub)
1650+
require.False(t, sub.GetSubscribed())
1651+
require.True(t, sub.GetIgnored())
1652+
require.Equal(t, 204, resp2.StatusCode)
16521653
}
16531654

1654-
func TestE2E_ManageRepositoryNotificationSubscription(t *testing.T) {
1655+
func ManageRepositoryNotificationSubscription(t *testing.T) {
16551656
skipIfGlobalMutationNotOptedIn(t)
16561657
t.Parallel()
16571658
client := setupMCPClient(t)
@@ -1722,13 +1723,14 @@ func TestE2E_ManageRepositoryNotificationSubscription(t *testing.T) {
17221723

17231724
// Validate with REST client
17241725
sub, resp2, err := restClient.Activity.GetRepositorySubscription(ctx, owner, repo)
1725-
// According to GitHub API, a deleted subscription returns 404
1726-
require.Error(t, err)
1727-
require.Nil(t, sub)
1728-
require.Equal(t, 404, resp2.StatusCode)
1726+
require.NoError(t, err)
1727+
require.NotNil(t, sub)
1728+
require.False(t, sub.GetSubscribed())
1729+
require.True(t, sub.GetIgnored())
1730+
require.Equal(t, 204, resp2.StatusCode)
17291731
}
17301732

1731-
func TestE2E_DismissNotification(t *testing.T) {
1733+
func DismissNotification(t *testing.T) {
17321734
skipIfGlobalMutationNotOptedIn(t)
17331735
t.Parallel()
17341736
client := setupMCPClient(t)
@@ -1769,7 +1771,7 @@ func TestE2E_DismissNotification(t *testing.T) {
17691771
require.Contains(t, textContent.Text, "read")
17701772
}
17711773

1772-
func TestE2E_MarkAllNotificationsRead(t *testing.T) {
1774+
func MarkAllNotificationsRead(t *testing.T) {
17731775
skipIfGlobalMutationNotOptedIn(t)
17741776
t.Parallel()
17751777
client := setupMCPClient(t)
@@ -1796,7 +1798,7 @@ func nowMinusOneHourRFC3339() string {
17961798
return time.Now().UTC().Add(-1 * time.Hour).Format(time.RFC3339)
17971799
}
17981800

1799-
func TestE2E_GetNotificationDetails(t *testing.T) {
1801+
func GetNotificationDetails(t *testing.T) {
18001802
t.Parallel()
18011803
client := setupMCPClient(t)
18021804
ctx := context.Background()
@@ -1816,6 +1818,9 @@ func TestE2E_GetNotificationDetails(t *testing.T) {
18161818
err = json.Unmarshal([]byte(textContent.Text), &notifications)
18171819
require.NoError(t, err)
18181820
require.NotEmpty(t, notifications)
1821+
if len(notifications) == 0 {
1822+
t.Skip("No notifications available to test dismissal")
1823+
}
18191824
notificationID := notifications[0].ID
18201825

18211826
// Get notification details

pkg/github/notifications.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,10 @@ func DismissNotification(getclient GetClientFn, t translations.TranslationHelper
180180
return mcp.NewToolResultError(fmt.Sprintf("invalid threadID format: %v", err)), nil
181181
}
182182
resp, err = client.Activity.MarkThreadDone(ctx, threadIDInt)
183-
} else {
183+
} else if state == "read" {
184184
resp, err = client.Activity.MarkThreadRead(ctx, threadID)
185+
} else {
186+
return mcp.NewToolResultError("Invalid state. Must be one of: read, done."), nil
185187
}
186188

187189
if err != nil {

0 commit comments

Comments
 (0)