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

Function Test_RequiredInt

pkg/github/params_test.go:152–272  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func Test_RequiredInt(t *testing.T) {
153 tests := []struct {
154 name string
155 params map[string]any
156 paramName string
157 expected int
158 expectError bool
159 }{
160 {
161 name: "valid number parameter",
162 params: map[string]any{"count": float64(42)},
163 paramName: "count",
164 expected: 42,
165 expectError: false,
166 },
167 {
168 name: "valid string number parameter",
169 params: map[string]any{"count": "42"},
170 paramName: "count",
171 expected: 42,
172 expectError: false,
173 },
174 {
175 name: "missing parameter",
176 params: map[string]any{},
177 paramName: "count",
178 expected: 0,
179 expectError: true,
180 },
181 {
182 name: "zero string parameter",
183 params: map[string]any{"count": "0"},
184 paramName: "count",
185 expected: 0,
186 expectError: true,
187 },
188 {
189 name: "wrong type parameter",
190 params: map[string]any{"count": "not-a-number"},
191 paramName: "count",
192 expected: 0,
193 expectError: true,
194 },
195 {
196 name: "boolean type parameter",
197 params: map[string]any{"count": true},
198 paramName: "count",
199 expected: 0,
200 expectError: true,
201 },
202 {
203 name: "NaN string",
204 params: map[string]any{"count": "NaN"},
205 paramName: "count",
206 expected: 0,
207 expectError: true,
208 },
209 {

Callers

nothing calls this directly

Calls 2

RequiredIntFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected