(t *testing.T)
| 3567 | } |
| 3568 | |
| 3569 | func TestGetMapFromFormData(t *testing.T) { |
| 3570 | testCases := []struct { |
| 3571 | name string |
| 3572 | data map[string][]string |
| 3573 | key string |
| 3574 | expected map[string]string |
| 3575 | found bool |
| 3576 | }{ |
| 3577 | { |
| 3578 | name: "Basic bracket notation", |
| 3579 | data: map[string][]string{ |
| 3580 | "ids[a]": {"hi"}, |
| 3581 | "ids[b]": {"3.14"}, |
| 3582 | }, |
| 3583 | key: "ids", |
| 3584 | expected: map[string]string{ |
| 3585 | "a": "hi", |
| 3586 | "b": "3.14", |
| 3587 | }, |
| 3588 | found: true, |
| 3589 | }, |
| 3590 | { |
| 3591 | name: "Mixed data with bracket notation", |
| 3592 | data: map[string][]string{ |
| 3593 | "ids[a]": {"hi"}, |
| 3594 | "ids[b]": {"3.14"}, |
| 3595 | "names[a]": {"mike"}, |
| 3596 | "names[b]": {"maria"}, |
| 3597 | "other[key]": {"value"}, |
| 3598 | "simple": {"data"}, |
| 3599 | }, |
| 3600 | key: "ids", |
| 3601 | expected: map[string]string{ |
| 3602 | "a": "hi", |
| 3603 | "b": "3.14", |
| 3604 | }, |
| 3605 | found: true, |
| 3606 | }, |
| 3607 | { |
| 3608 | name: "Names key", |
| 3609 | data: map[string][]string{ |
| 3610 | "ids[a]": {"hi"}, |
| 3611 | "ids[b]": {"3.14"}, |
| 3612 | "names[a]": {"mike"}, |
| 3613 | "names[b]": {"maria"}, |
| 3614 | "other[key]": {"value"}, |
| 3615 | }, |
| 3616 | key: "names", |
| 3617 | expected: map[string]string{ |
| 3618 | "a": "mike", |
| 3619 | "b": "maria", |
| 3620 | }, |
| 3621 | found: true, |
| 3622 | }, |
| 3623 | { |
| 3624 | name: "Key not found", |
| 3625 | data: map[string][]string{ |
| 3626 | "ids[a]": {"hi"}, |
nothing calls this directly
no test coverage detected
searching dependent graphs…