MCPcopy
hub / github.com/pocketbase/pocketbase / TestRecordCustomData

Function TestRecordCustomData

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

Source from the content-addressed store, hash-verified

676}
677
678func TestRecordCustomData(t *testing.T) {
679 t.Parallel()
680
681 collection := core.NewAuthCollection("test")
682 collection.Fields.Add(&core.TextField{Name: "field1"})
683 collection.Fields.Add(&core.TextField{Name: "field2"})
684
685 m := core.NewRecord(collection)
686 m.Id = "test_id" // direct id assignment
687 m.Set("email", "test@example.com")
688 m.Set("password", "123") // hidden fields should be also returned
689 m.Set("tokenKey", "789")
690 m.Set("field1", 123)
691 m.Set("field2", 456)
692 m.Set("unknown", 789)
693
694 raw, err := json.Marshal(m.CustomData())
695 if err != nil {
696 t.Fatal(err)
697 }
698
699 expected := `{"unknown":789}`
700
701 if v := string(raw); v != expected {
702 t.Fatalf("Expected\n%v\ngot\n%v", expected, v)
703 }
704}
705
706func TestRecordSetGet(t *testing.T) {
707 t.Parallel()

Callers

nothing calls this directly

Calls 5

SetMethod · 0.95
CustomDataMethod · 0.95
NewAuthCollectionFunction · 0.92
NewRecordFunction · 0.92
AddMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…