MCPcopy
hub / github.com/pocketbase/pocketbase / TestFileFieldFindSetter

Function TestFileFieldFindSetter

core/field_file_test.go:711–826  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

709}
710
711func 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 {

Callers

nothing calls this directly

Calls 8

SetRawMethod · 0.95
GetMethod · 0.95
NewBaseCollectionFunction · 0.92
NewRecordFunction · 0.92
FindSetterMethod · 0.65
GetNameMethod · 0.65
RunMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…