MCPcopy
hub / github.com/github/github-mcp-server / TestAssignCopilotToIssue

Function TestAssignCopilotToIssue

pkg/github/copilot_test.go:20–851  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18)
19
20func TestAssignCopilotToIssue(t *testing.T) {
21 t.Parallel()
22
23 // Verify tool definition
24 serverTool := AssignCopilotToIssue(translations.NullTranslationHelper)
25 tool := serverTool.Tool
26 require.NoError(t, toolsnaps.Test(tool.Name, tool))
27
28 assert.Equal(t, "assign_copilot_to_issue", tool.Name)
29 assert.NotEmpty(t, tool.Description)
30 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "owner")
31 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "repo")
32 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "issue_number")
33 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "base_ref")
34 assert.Contains(t, tool.InputSchema.(*jsonschema.Schema).Properties, "custom_instructions")
35 assert.ElementsMatch(t, tool.InputSchema.(*jsonschema.Schema).Required, []string{"owner", "repo", "issue_number"})
36
37 // Helper function to create pointer to githubv4.String
38 ptrGitHubv4String := func(s string) *githubv4.String {
39 v := githubv4.String(s)
40 return &v
41 }
42
43 var pageOfFakeBots = func(n int) []struct{} {
44 // We don't _really_ need real bots here, just objects that count as entries for the page
45 bots := make([]struct{}, n)
46 for i := range n {
47 bots[i] = struct{}{}
48 }
49 return bots
50 }
51
52 tests := []struct {
53 name string
54 requestArgs map[string]any
55 mockedClient *http.Client
56 expectToolError bool
57 expectedToolErrMsg string
58 }{
59 {
60 name: "successful assignment when there are no existing assignees",
61 requestArgs: map[string]any{
62 "owner": "owner",
63 "repo": "repo",
64 "issue_number": float64(123),
65 },
66 mockedClient: githubv4mock.NewMockedHTTPClient(
67 githubv4mock.NewQueryMatcher(
68 struct {
69 Repository struct {
70 SuggestedActors struct {
71 Nodes []struct {
72 Bot struct {
73 ID githubv4.ID
74 Login githubv4.String
75 TypeName string `graphql:"__typename"`
76 } `graphql:"... on Bot"`
77 }

Callers

nothing calls this directly

Calls 12

TestFunction · 0.92
NewMockedHTTPClientFunction · 0.92
NewQueryMatcherFunction · 0.92
DataResponseFunction · 0.92
NewMutationMatcherFunction · 0.92
AssignCopilotToIssueFunction · 0.85
createMCPRequestFunction · 0.85
ContextWithPollConfigFunction · 0.85
ContextWithDepsFunction · 0.85
getTextResultFunction · 0.85
StringMethod · 0.45
HandlerMethod · 0.45

Tested by

no test coverage detected