MCPcopy Create free account
hub / github.com/pocketbase/pocketbase / TestSubscriptions

Function TestSubscriptions

tools/subscriptions/client_test.go:61–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestSubscriptions(t *testing.T) {
62 c := subscriptions.NewDefaultClient()
63
64 if len(c.Subscriptions()) != 0 {
65 t.Fatalf("Expected subscriptions to be empty")
66 }
67
68 c.Subscribe("sub1", "sub11", "sub2")
69
70 scenarios := []struct {
71 prefixes []string
72 expected []string
73 }{
74 {nil, []string{"sub1", "sub11", "sub2"}},
75 {[]string{"missing"}, nil},
76 {[]string{"sub1"}, []string{"sub1", "sub11"}},
77 {[]string{"sub2"}, []string{"sub2"}}, // with extra query start char
78 }
79
80 for _, s := range scenarios {
81 t.Run(strings.Join(s.prefixes, ","), func(t *testing.T) {
82 subs := c.Subscriptions(s.prefixes...)
83
84 if len(subs) != len(s.expected) {
85 t.Fatalf("Expected %d subscriptions, got %d", len(s.expected), len(subs))
86 }
87
88 for _, s := range s.expected {
89 if _, ok := subs[s]; !ok {
90 t.Fatalf("Missing subscription %q in \n%v", s, subs)
91 }
92 }
93 })
94 }
95}
96
97func TestSubscribe(t *testing.T) {
98 c := subscriptions.NewDefaultClient()

Callers

nothing calls this directly

Calls 4

SubscriptionsMethod · 0.95
SubscribeMethod · 0.95
NewDefaultClientFunction · 0.92
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…