-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Adding default toolset as configuration #1229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bb4e2d9
add toolset default to make configuration easier
tonytrg 7cdf26f
fix readme
tonytrg 8d2995d
adding transformer to cleanly handle special toolsets
tonytrg 4993295
Merge branch 'main' into tonytrg/add-default
tonytrg 69b1a3a
cleaning code
tonytrg b37be61
Merge branch 'tonytrg/add-default' of github.com:github/github-mcp-se…
tonytrg 0c8980d
fixing cli message
tonytrg 5dfeaca
remove duplicated test
tonytrg 6c9c201
Update internal/ghmcp/server.go
tonytrg d786306
Update internal/ghmcp/server_test.go
tonytrg 5390807
adding error message for invalid toolsets
tonytrg 809a8fc
adding error message
tonytrg 40fbb6c
fix merge conflict
tonytrg f42f866
add better formatting
tonytrg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,244 @@ | ||
| package ghmcp | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestCleanToolsets(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| input []string | ||
| dynamicToolsets bool | ||
| expected []string | ||
| }{ | ||
| { | ||
| name: "empty slice", | ||
| input: []string{}, | ||
| dynamicToolsets: false, | ||
| expected: []string{}, | ||
| }, | ||
| { | ||
| name: "nil input slice", | ||
| input: nil, | ||
| dynamicToolsets: false, | ||
| expected: []string{}, | ||
| }, | ||
| // all test cases | ||
| { | ||
| name: "all only", | ||
| input: []string{"all"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"all"}, | ||
| }, | ||
| { | ||
| name: "all appears multiple times", | ||
| input: []string{"all", "actions", "all"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"all"}, | ||
| }, | ||
| { | ||
| name: "all with other toolsets", | ||
| input: []string{"all", "actions", "gists"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"all"}, | ||
| }, | ||
| { | ||
| name: "all with default", | ||
| input: []string{"default", "all", "actions"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"all"}, | ||
| }, | ||
| // default test cases | ||
| { | ||
| name: "default only", | ||
| input: []string{"default"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{ | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "default with additional toolsets", | ||
| input: []string{"default", "actions", "gists"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{ | ||
| "actions", | ||
| "gists", | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "no default present", | ||
| input: []string{"actions", "gists", "notifications"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"actions", "gists", "notifications"}, | ||
| }, | ||
| { | ||
| name: "duplicate toolsets without default", | ||
| input: []string{"actions", "gists", "actions"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"actions", "gists"}, | ||
| }, | ||
| { | ||
| name: "duplicate toolsets with default", | ||
| input: []string{"context", "repos", "issues", "pull_requests", "users", "default"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{ | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "default appears multiple times with different toolsets in between", | ||
| input: []string{"default", "actions", "default", "gists", "default"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{ | ||
| "actions", | ||
| "gists", | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| // Dynamic toolsets test cases | ||
| { | ||
| name: "dynamic toolsets - all only should be filtered", | ||
| input: []string{"all"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{}, | ||
| }, | ||
| { | ||
| name: "dynamic toolsets - all with other toolsets", | ||
| input: []string{"all", "actions", "gists"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{"actions", "gists"}, | ||
| }, | ||
| { | ||
| name: "dynamic toolsets - all with default", | ||
| input: []string{"all", "default", "actions"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{ | ||
| "actions", | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "dynamic toolsets - no all present", | ||
| input: []string{"actions", "gists"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{"actions", "gists"}, | ||
| }, | ||
| { | ||
| name: "dynamic toolsets - default only", | ||
| input: []string{"default"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{ | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "only special keywords with dynamic mode", | ||
| input: []string{"all", "default"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{ | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "all with default and overlapping default toolsets in dynamic mode", | ||
| input: []string{"all", "default", "issues", "repos"}, | ||
| dynamicToolsets: true, | ||
| expected: []string{ | ||
| "issues", | ||
| "repos", | ||
| "context", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| // Whitespace test cases | ||
| { | ||
| name: "whitespace check- leading and trailing whitespace on regular toolsets", | ||
tonytrg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| input: []string{" actions ", " gists ", "notifications"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"actions", "gists", "notifications"}, | ||
| }, | ||
| { | ||
| name: "whitespace check - default toolset", | ||
| input: []string{" actions ", " default ", "notifications"}, | ||
| dynamicToolsets: false, | ||
| expected: []string{ | ||
| "actions", | ||
| "notifications", | ||
| "context", | ||
| "repos", | ||
| "issues", | ||
| "pull_requests", | ||
| "users", | ||
| }, | ||
| }, | ||
| { | ||
| name: "whitespace check - all toolset", | ||
| input: []string{" actions ", " gists ", "notifications", " all "}, | ||
| dynamicToolsets: false, | ||
| expected: []string{"all"}, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| result := cleanToolsets(tt.input, tt.dynamicToolsets) | ||
|
|
||
| // Check that the result has the correct length | ||
| require.Len(t, result, len(tt.expected), "result length should match expected length") | ||
|
|
||
| // Create a map for easier comparison since order might vary | ||
| resultMap := make(map[string]bool) | ||
| for _, toolset := range result { | ||
| resultMap[toolset] = true | ||
| } | ||
|
|
||
| expectedMap := make(map[string]bool) | ||
| for _, toolset := range tt.expected { | ||
| expectedMap[toolset] = true | ||
| } | ||
|
|
||
| // Check that both maps contain the same toolsets | ||
| assert.Equal(t, expectedMap, resultMap, "result should contain all expected toolsets without duplicates") | ||
|
|
||
| // Verify no duplicates in result | ||
| assert.Len(t, resultMap, len(result), "result should not contain duplicates") | ||
|
|
||
| // Verify "default" is not in the result | ||
| assert.False(t, resultMap["default"], "result should not contain 'default'") | ||
| }) | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.