MCPcopy
hub / github.com/pocketbase/pocketbase / TestNewViewCollection

Function TestNewViewCollection

core/collection_model_test.go:203–255  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func TestNewViewCollection(t *testing.T) {
204 t.Parallel()
205
206 scenarios := []struct {
207 name string
208 expected []string
209 }{
210 {
211 "",
212 []string{
213 `"id":"pbc_`,
214 `"name":""`,
215 `"type":"view"`,
216 `"indexes":[]`,
217 `"fields":[]`,
218 `"system":false`,
219 `"listRule":null`,
220 `"viewRule":null`,
221 `"createRule":null`,
222 `"updateRule":null`,
223 `"deleteRule":null`,
224 },
225 },
226 {
227 "test",
228 []string{
229 `"id":"pbc_`,
230 `"name":"test"`,
231 `"type":"view"`,
232 `"indexes":[]`,
233 `"fields":[]`,
234 `"system":false`,
235 `"listRule":null`,
236 `"viewRule":null`,
237 `"createRule":null`,
238 `"updateRule":null`,
239 `"deleteRule":null`,
240 },
241 },
242 }
243
244 for i, s := range scenarios {
245 t.Run(fmt.Sprintf("%d_%s", i, s.name), func(t *testing.T) {
246 result := core.NewViewCollection(s.name).String()
247
248 for _, part := range s.expected {
249 if !strings.Contains(result, part) {
250 t.Fatalf("Missing part %q in\n%v", part, result)
251 }
252 }
253 })
254 }
255}
256
257func TestNewAuthCollection(t *testing.T) {
258 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewViewCollectionFunction · 0.92
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…