(t *testing.T)
| 709 | } |
| 710 | |
| 711 | func TestFileFieldFindSetter(t *testing.T) { |
| 712 | scenarios := []struct { |
| 713 | name string |
| 714 | key string |
| 715 | value any |
| 716 | field *core.FileField |
| 717 | hasSetter bool |
| 718 | expected string |
| 719 | }{ |
| 720 | { |
| 721 | "no match", |
| 722 | "example", |
| 723 | "b", |
| 724 | &core.FileField{Name: "test", MaxSelect: 1}, |
| 725 | false, |
| 726 | "", |
| 727 | }, |
| 728 | { |
| 729 | "exact match (single)", |
| 730 | "test", |
| 731 | "b", |
| 732 | &core.FileField{Name: "test", MaxSelect: 1}, |
| 733 | true, |
| 734 | `"b"`, |
| 735 | }, |
| 736 | { |
| 737 | "exact match (multiple)", |
| 738 | "test", |
| 739 | []string{"a", "b", "b"}, |
| 740 | &core.FileField{Name: "test", MaxSelect: 2}, |
| 741 | true, |
| 742 | `["a","b"]`, |
| 743 | }, |
| 744 | { |
| 745 | "append (single)", |
| 746 | "test+", |
| 747 | "b", |
| 748 | &core.FileField{Name: "test", MaxSelect: 1}, |
| 749 | true, |
| 750 | `"b"`, |
| 751 | }, |
| 752 | { |
| 753 | "append (multiple)", |
| 754 | "test+", |
| 755 | []string{"a"}, |
| 756 | &core.FileField{Name: "test", MaxSelect: 2}, |
| 757 | true, |
| 758 | `["c","d","a"]`, |
| 759 | }, |
| 760 | { |
| 761 | "prepend (single)", |
| 762 | "+test", |
| 763 | "b", |
| 764 | &core.FileField{Name: "test", MaxSelect: 1}, |
| 765 | true, |
| 766 | `"d"`, // the last of the existing values |
| 767 | }, |
| 768 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…