(t *testing.T)
| 2123 | } |
| 2124 | |
| 2125 | func Test_PushFiles(t *testing.T) { |
| 2126 | // Verify tool definition once |
| 2127 | serverTool := PushFiles(translations.NullTranslationHelper) |
| 2128 | tool := serverTool.Tool |
| 2129 | require.NoError(t, toolsnaps.Test(tool.Name, tool)) |
| 2130 | |
| 2131 | schema, ok := tool.InputSchema.(*jsonschema.Schema) |
| 2132 | require.True(t, ok, "InputSchema should be *jsonschema.Schema") |
| 2133 | |
| 2134 | assert.Equal(t, "push_files", tool.Name) |
| 2135 | assert.NotEmpty(t, tool.Description) |
| 2136 | assert.Contains(t, schema.Properties, "owner") |
| 2137 | assert.Contains(t, schema.Properties, "repo") |
| 2138 | assert.Contains(t, schema.Properties, "branch") |
| 2139 | assert.Contains(t, schema.Properties, "files") |
| 2140 | assert.Contains(t, schema.Properties, "message") |
| 2141 | assert.ElementsMatch(t, schema.Required, []string{"owner", "repo", "branch", "files", "message"}) |
| 2142 | |
| 2143 | // Setup mock objects |
| 2144 | mockRef := &github.Reference{ |
| 2145 | Ref: github.Ptr("refs/heads/main"), |
| 2146 | Object: &github.GitObject{ |
| 2147 | SHA: github.Ptr("abc123"), |
| 2148 | URL: github.Ptr("https://api.github.com/repos/owner/repo/git/trees/abc123"), |
| 2149 | }, |
| 2150 | } |
| 2151 | |
| 2152 | mockCommit := &github.Commit{ |
| 2153 | SHA: github.Ptr("abc123"), |
| 2154 | Tree: &github.Tree{ |
| 2155 | SHA: github.Ptr("def456"), |
| 2156 | }, |
| 2157 | } |
| 2158 | |
| 2159 | mockTree := &github.Tree{ |
| 2160 | SHA: github.Ptr("ghi789"), |
| 2161 | } |
| 2162 | |
| 2163 | mockNewCommit := &github.Commit{ |
| 2164 | SHA: github.Ptr("jkl012"), |
| 2165 | Message: github.Ptr("Update multiple files"), |
| 2166 | HTMLURL: github.Ptr("https://github.com/owner/repo/commit/jkl012"), |
| 2167 | } |
| 2168 | |
| 2169 | mockUpdatedRef := &github.Reference{ |
| 2170 | Ref: github.Ptr("refs/heads/main"), |
| 2171 | Object: &github.GitObject{ |
| 2172 | SHA: github.Ptr("jkl012"), |
| 2173 | URL: github.Ptr("https://api.github.com/repos/owner/repo/git/trees/jkl012"), |
| 2174 | }, |
| 2175 | } |
| 2176 | |
| 2177 | // Define test cases |
| 2178 | tests := []struct { |
| 2179 | name string |
| 2180 | mockedClient *http.Client |
| 2181 | requestArgs map[string]any |
| 2182 | expectError bool |
nothing calls this directly
no test coverage detected