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

Function TestCollectionPostScan

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

Source from the content-addressed store, hash-verified

429}
430
431func TestCollectionPostScan(t *testing.T) {
432 t.Parallel()
433
434 rawOptions := types.JSONRaw(`{
435 "viewQuery":"select 1",
436 "authRule":"1=2"
437 }`)
438
439 scenarios := []struct {
440 typ string
441 rawOptions types.JSONRaw
442 expected []string
443 }{
444 {
445 core.CollectionTypeBase,
446 rawOptions,
447 []string{
448 `lastSavedPK:"test"`,
449 `ViewQuery:""`,
450 `AuthRule:(*string)(nil)`,
451 },
452 },
453 {
454 core.CollectionTypeView,
455 rawOptions,
456 []string{
457 `lastSavedPK:"test"`,
458 `ViewQuery:"select 1"`,
459 `AuthRule:(*string)(nil)`,
460 },
461 },
462 {
463 core.CollectionTypeAuth,
464 rawOptions,
465 []string{
466 `lastSavedPK:"test"`,
467 `ViewQuery:""`,
468 `AuthRule:(*string)(0x`,
469 },
470 },
471 }
472
473 for i, s := range scenarios {
474 t.Run(fmt.Sprintf("%d_%s", i, s.typ), func(t *testing.T) {
475 c := core.Collection{}
476 c.Id = "test"
477 c.Type = s.typ
478 c.RawOptions = s.rawOptions
479
480 err := c.PostScan()
481 if err != nil {
482 t.Fatal(err)
483 }
484
485 if c.IsNew() {
486 t.Fatal("Expected the collection to be marked as not new")
487 }
488

Callers

nothing calls this directly

Calls 4

PostScanMethod · 0.95
JSONRawTypeAlias · 0.92
IsNewMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…