MCPcopy
hub / github.com/pocketbase/pocketbase / TestRealtimeAuthRecordUpdateEvent

Function TestRealtimeAuthRecordUpdateEvent

apis/realtime_test.go:521–558  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

519}
520
521func TestRealtimeAuthRecordUpdateEvent(t *testing.T) {
522 testApp, _ := tests.NewTestApp()
523 defer testApp.Cleanup()
524
525 // init realtime handlers
526 _, err := apis.NewRouter(testApp)
527 if err != nil {
528 t.Fatal(err)
529 }
530
531 authRecord1, err := testApp.FindAuthRecordByEmail("users", "test@example.com")
532 if err != nil {
533 t.Fatal(err)
534 }
535
536 client := subscriptions.NewDefaultClient()
537 client.Set(apis.RealtimeClientAuthKey, authRecord1)
538 testApp.SubscriptionsBroker().Register(client)
539
540 // refetch the authRecord and change its name
541 authRecord2, err := testApp.FindAuthRecordByEmail("users", "test@example.com")
542 if err != nil {
543 t.Fatal(err)
544 }
545
546 newName := "test_new_name"
547 authRecord2.Set("name", newName)
548
549 err = testApp.Save(authRecord2)
550 if err != nil {
551 t.Fatal(err)
552 }
553
554 clientAuthRecord, _ := client.Get(apis.RealtimeClientAuthKey).(*core.Record)
555 if clientAuthRecord.Get("name") != newName {
556 t.Fatalf("Expected authRecord with email %q, got %q", newName, clientAuthRecord.Email())
557 }
558}
559
560func TestRealtimeRecordHiddenFields(t *testing.T) {
561 t.Parallel()

Callers

nothing calls this directly

Calls 13

CleanupMethod · 0.95
SetMethod · 0.95
GetMethod · 0.95
NewTestAppFunction · 0.92
NewRouterFunction · 0.92
NewDefaultClientFunction · 0.92
EmailMethod · 0.80
FindAuthRecordByEmailMethod · 0.65
SubscriptionsBrokerMethod · 0.65
SetMethod · 0.65
SaveMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…