MCPcopy
hub / github.com/pocketbase/pocketbase / TestRecordExpandedOne

Function TestRecordExpandedOne

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

Source from the content-addressed store, hash-verified

580}
581
582func TestRecordExpandedOne(t *testing.T) {
583 t.Parallel()
584
585 collection := core.NewBaseCollection("test")
586
587 main := core.NewRecord(collection)
588
589 single := core.NewRecord(collection)
590 single.Id = "single"
591
592 multiple1 := core.NewRecord(collection)
593 multiple1.Id = "multiple1"
594
595 multiple2 := core.NewRecord(collection)
596 multiple2.Id = "multiple2"
597
598 main.SetExpand(map[string]any{
599 "single": single,
600 "multiple": []*core.Record{multiple1, multiple2},
601 })
602
603 if v := main.ExpandedOne("missing"); v != nil {
604 t.Fatalf("Expected nil, got %v", v)
605 }
606
607 if v := main.ExpandedOne("single"); v == nil || v.Id != "single" {
608 t.Fatalf("Expected record with id %q, got %v", "single", v)
609 }
610
611 if v := main.ExpandedOne("multiple"); v == nil || v.Id != "multiple1" {
612 t.Fatalf("Expected record with id %q, got %v", "multiple1", v)
613 }
614}
615
616func TestRecordExpandedAll(t *testing.T) {
617 t.Parallel()

Callers

nothing calls this directly

Calls 4

SetExpandMethod · 0.95
ExpandedOneMethod · 0.95
NewBaseCollectionFunction · 0.92
NewRecordFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…