-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathserver_test.go
More file actions
42 lines (35 loc) · 1.24 KB
/
server_test.go
File metadata and controls
42 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package ghmcp
import (
"context"
"io"
"log/slog"
"testing"
"github.com/github/github-mcp-server/pkg/github"
"github.com/github/github-mcp-server/pkg/inventory"
"github.com/github/github-mcp-server/pkg/translations"
"github.com/stretchr/testify/require"
)
func TestNewStdioMCPServer_StrictToolsetValidation(t *testing.T) {
t.Parallel()
_, err := NewStdioMCPServer(context.Background(), testMCPServerConfig([]string{"repos", "typo"}, true))
require.Error(t, err)
require.ErrorIs(t, err, inventory.ErrUnknownToolsets)
require.Contains(t, err.Error(), "typo")
}
func TestNewStdioMCPServer_AllowsUnknownToolsetsWhenNotStrict(t *testing.T) {
t.Parallel()
server, err := NewStdioMCPServer(context.Background(), testMCPServerConfig([]string{"repos", "typo"}, false))
require.NoError(t, err)
require.NotNil(t, server)
}
func testMCPServerConfig(toolsets []string, strict bool) github.MCPServerConfig {
return github.MCPServerConfig{
Version: "test",
Token: "test-token",
EnabledToolsets: toolsets,
StrictToolsetValidation: strict,
Translator: translations.NullTranslationHelper,
ContentWindowSize: 5000,
Logger: slog.New(slog.NewTextHandler(io.Discard, nil)),
}
}