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

Function Test_OptionalIntParam

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

Source from the content-addressed store, hash-verified

271 }
272}
273func Test_OptionalIntParam(t *testing.T) {
274 tests := []struct {
275 name string
276 params map[string]any
277 paramName string
278 expected int
279 expectError bool
280 }{
281 {
282 name: "valid number parameter",
283 params: map[string]any{"count": float64(42)},
284 paramName: "count",
285 expected: 42,
286 expectError: false,
287 },
288 {
289 name: "valid string number parameter",
290 params: map[string]any{"count": "42"},
291 paramName: "count",
292 expected: 42,
293 expectError: false,
294 },
295 {
296 name: "missing parameter",
297 params: map[string]any{},
298 paramName: "count",
299 expected: 0,
300 expectError: false,
301 },
302 {
303 name: "zero value",
304 params: map[string]any{"count": float64(0)},
305 paramName: "count",
306 expected: 0,
307 expectError: false,
308 },
309 {
310 name: "zero string value",
311 params: map[string]any{"count": "0"},
312 paramName: "count",
313 expected: 0,
314 expectError: false,
315 },
316 {
317 name: "wrong type parameter",
318 params: map[string]any{"count": "not-a-number"},
319 paramName: "count",
320 expected: 0,
321 expectError: true,
322 },
323 {
324 name: "NaN string",
325 params: map[string]any{"count": "NaN"},
326 paramName: "count",
327 expected: 0,
328 expectError: true,
329 },
330 {

Callers

nothing calls this directly

Calls 2

OptionalIntParamFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected