MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / TestFormData_Int

Function TestFormData_Int

pkg/modules/api/formdata_test.go:317–397  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

315}
316
317func TestFormData_Int(t *testing.T) {
318 for _, tc := range []struct {
319 scenario string
320 form *FormData
321 defaultValue int
322 expect int
323 expectError bool
324 }{
325 {
326 scenario: "key does not exist, fallback to default zero value",
327 form: &FormData{},
328 defaultValue: 0,
329 expect: 0,
330 expectError: false,
331 },
332 {
333 scenario: "key does not exist, fallback to default value",
334 form: &FormData{},
335 defaultValue: 2,
336 expect: 2,
337 expectError: false,
338 },
339 {
340 scenario: "key does exist, but empty value, fallback to default value",
341 form: &FormData{
342 values: map[string][]string{
343 "foo": {
344 "",
345 },
346 },
347 },
348 defaultValue: 0,
349 expect: 0,
350 expectError: false,
351 },
352 {
353 scenario: "key does exist, but value is invalid",
354 form: &FormData{
355 values: map[string][]string{
356 "foo": {
357 "foo",
358 },
359 },
360 },
361 defaultValue: 0,
362 expect: 0,
363 expectError: true,
364 },
365 {
366 scenario: "key does exist with a value",
367 form: &FormData{
368 values: map[string][]string{
369 "foo": {
370 "3",
371 },
372 },
373 },
374 defaultValue: 0,

Callers

nothing calls this directly

Calls 2

IntMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected