MCPcopy
hub / github.com/pocketbase/pocketbase / TestTextFieldFindSetter

Function TestTextFieldFindSetter

core/field_text_test.go:675–745  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

673}
674
675func TestTextFieldFindSetter(t *testing.T) {
676 scenarios := []struct {
677 name string
678 key string
679 value any
680 field *core.TextField
681 hasSetter bool
682 expected string
683 }{
684 {
685 "no match",
686 "example",
687 "abc",
688 &core.TextField{Name: "test", AutogeneratePattern: "test"},
689 false,
690 "",
691 },
692 {
693 "exact match",
694 "test",
695 "abc",
696 &core.TextField{Name: "test", AutogeneratePattern: "test"},
697 true,
698 "abc",
699 },
700 {
701 "autogenerate modifier",
702 "test:autogenerate",
703 "abc",
704 &core.TextField{Name: "test", AutogeneratePattern: "test"},
705 true,
706 "abctest",
707 },
708 {
709 "autogenerate modifier without AutogeneratePattern option",
710 "test:autogenerate",
711 "abc",
712 &core.TextField{Name: "test"},
713 true,
714 "abc",
715 },
716 }
717
718 for _, s := range scenarios {
719 t.Run(s.name, func(t *testing.T) {
720 collection := core.NewBaseCollection("test_collection")
721 collection.Fields.Add(s.field)
722
723 setter := s.field.FindSetter(s.key)
724
725 hasSetter := setter != nil
726 if hasSetter != s.hasSetter {
727 t.Fatalf("Expected hasSetter %v, got %v", s.hasSetter, hasSetter)
728 }
729
730 if !hasSetter {
731 return
732 }

Callers

nothing calls this directly

Calls 6

GetStringMethod · 0.95
NewBaseCollectionFunction · 0.92
NewRecordFunction · 0.92
FindSetterMethod · 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…