Skip to content

Commit 6fa8eaf

Browse files
tonytrgSamMorrowDrums
authored andcommitted
adding tests
1 parent b031f21 commit 6fa8eaf

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

pkg/github/__toolsnaps__/get_file_contents.snap

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
"description": "Get the contents of a file or directory from a GitHub repository",
77
"inputSchema": {
88
"properties": {
9-
"branch": {
10-
"description": "Branch to get contents from",
11-
"type": "string"
12-
},
139
"owner": {
1410
"description": "Repository owner (username or organization)",
1511
"type": "string"
@@ -18,9 +14,17 @@
1814
"description": "Path to file/directory (directories must end with a slash '/')",
1915
"type": "string"
2016
},
17+
"ref": {
18+
"description": "Accepts optional git refs such as `refs/tags/\u003ctag\u003e`, `refs/heads/\u003cbranch\u003e` or `refs/pull/\u003cpr_number\u003e/head`",
19+
"type": "string"
20+
},
2121
"repo": {
2222
"description": "Repository name",
2323
"type": "string"
24+
},
25+
"sha": {
26+
"description": "Accepts optional git sha, if sha is specified it will be used instead of ref",
27+
"type": "string"
2428
}
2529
},
2630
"required": [

pkg/github/repositories_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ func Test_GetFileContents(t *testing.T) {
3131
assert.Contains(t, tool.InputSchema.Properties, "owner")
3232
assert.Contains(t, tool.InputSchema.Properties, "repo")
3333
assert.Contains(t, tool.InputSchema.Properties, "path")
34-
assert.Contains(t, tool.InputSchema.Properties, "branch")
34+
assert.Contains(t, tool.InputSchema.Properties, "ref")
35+
assert.Contains(t, tool.InputSchema.Properties, "sha")
3536
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"owner", "repo", "path"})
3637

3738
// Mock response for raw content
@@ -77,10 +78,10 @@ func Test_GetFileContents(t *testing.T) {
7778
),
7879
),
7980
requestArgs: map[string]interface{}{
80-
"owner": "owner",
81-
"repo": "repo",
82-
"path": "README.md",
83-
"branch": "main",
81+
"owner": "owner",
82+
"repo": "repo",
83+
"path": "README.md",
84+
"ref": "refs/heads/main",
8485
},
8586
expectError: false,
8687
expectedResult: mcp.TextResourceContents{
@@ -101,10 +102,10 @@ func Test_GetFileContents(t *testing.T) {
101102
),
102103
),
103104
requestArgs: map[string]interface{}{
104-
"owner": "owner",
105-
"repo": "repo",
106-
"path": "test.png",
107-
"branch": "main",
105+
"owner": "owner",
106+
"repo": "repo",
107+
"path": "test.png",
108+
"ref": "refs/heads/main",
108109
},
109110
expectError: false,
110111
expectedResult: mcp.BlobResourceContents{
@@ -158,10 +159,10 @@ func Test_GetFileContents(t *testing.T) {
158159
),
159160
),
160161
requestArgs: map[string]interface{}{
161-
"owner": "owner",
162-
"repo": "repo",
163-
"path": "nonexistent.md",
164-
"branch": "main",
162+
"owner": "owner",
163+
"repo": "repo",
164+
"path": "nonexistent.md",
165+
"ref": "refs/heads/main",
165166
},
166167
expectError: false,
167168
expectedResult: mcp.NewToolResultError("Failed to get file contents. The path does not point to a file or directory, or the file does not exist in the repository."),

0 commit comments

Comments
 (0)