MCPcopy Index your code
hub / github.com/pocketbase/pocketbase / TestSubscribeOptions

Function TestSubscribeOptions

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

Source from the content-addressed store, hash-verified

114}
115
116func TestSubscribeOptions(t *testing.T) {
117 c := subscriptions.NewDefaultClient()
118
119 sub1 := "test1"
120 sub2 := `test2?options={"query":{"name":123},"headers":{"X-Token":456}}`
121
122 c.Subscribe(sub1, sub2)
123
124 subs := c.Subscriptions()
125
126 scenarios := []struct {
127 name string
128 expectedOptions string
129 }{
130 {sub1, `{"query":{},"headers":{}}`},
131 {sub2, `{"query":{"name":"123"},"headers":{"x_token":"456"}}`},
132 }
133
134 for _, s := range scenarios {
135 t.Run(s.name, func(t *testing.T) {
136 options, ok := subs[s.name]
137 if !ok {
138 t.Fatalf("Missing subscription \n%q \nin \n%v", s.name, subs)
139 }
140
141 rawBytes, err := json.Marshal(options)
142 if err != nil {
143 t.Fatal(err)
144 }
145 rawStr := string(rawBytes)
146
147 if rawStr != s.expectedOptions {
148 t.Fatalf("Expected options\n%v\ngot\n%v", s.expectedOptions, rawStr)
149 }
150 })
151 }
152}
153
154func TestUnsubscribe(t *testing.T) {
155 c := subscriptions.NewDefaultClient()

Callers

nothing calls this directly

Calls 4

SubscribeMethod · 0.95
SubscriptionsMethod · 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…