MCPcopy
hub / github.com/pocketbase/pocketbase / TestRecordGetString

Function TestRecordGetString

core/record_model_test.go:832–864  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

830}
831
832func TestRecordGetString(t *testing.T) {
833 t.Parallel()
834
835 scenarios := []struct {
836 value any
837 expected string
838 }{
839 {nil, ""},
840 {"", ""},
841 {0, "0"},
842 {1.4, "1.4"},
843 {[]string{"true"}, ""},
844 {map[string]int{"test": 1}, ""},
845 {[]byte("abc"), "abc"},
846 {"test", "test"},
847 {false, "false"},
848 {true, "true"},
849 }
850
851 collection := core.NewBaseCollection("test")
852 record := core.NewRecord(collection)
853
854 for i, s := range scenarios {
855 t.Run(fmt.Sprintf("%d_%#v", i, s.value), func(t *testing.T) {
856 record.Set("test", s.value)
857
858 result := record.GetString("test")
859 if result != s.expected {
860 t.Fatalf("Expected %q, got %q", s.expected, result)
861 }
862 })
863 }
864}
865
866func TestRecordGetInt(t *testing.T) {
867 t.Parallel()

Callers

nothing calls this directly

Calls 5

SetMethod · 0.95
GetStringMethod · 0.95
NewBaseCollectionFunction · 0.92
NewRecordFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…