MCPcopy
hub / github.com/pocketbase/pocketbase / TestRealtimeCustomAuthModelUpdateEvent

Function TestRealtimeCustomAuthModelUpdateEvent

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

Source from the content-addressed store, hash-verified

955}
956
957func TestRealtimeCustomAuthModelUpdateEvent(t *testing.T) {
958 testApp, _ := tests.NewTestApp()
959 defer testApp.Cleanup()
960
961 // init realtime handlers
962 _, err := apis.NewRouter(testApp)
963 if err != nil {
964 t.Fatal(err)
965 }
966
967 authRecord, err := testApp.FindAuthRecordByEmail("users", "test@example.com")
968 if err != nil {
969 t.Fatal(err)
970 }
971
972 client := subscriptions.NewDefaultClient()
973 client.Set(apis.RealtimeClientAuthKey, authRecord)
974 testApp.SubscriptionsBroker().Register(client)
975
976 // refetch the authRecord as CustomUser
977 customUser, err := findCustomUserByEmail(testApp, "test@example.com")
978 if err != nil {
979 t.Fatal(err)
980 }
981
982 // change its email
983 customUser.Email = "new@example.com"
984 if err := testApp.Save(customUser); err != nil {
985 t.Fatal(err)
986 }
987
988 clientAuthRecord, _ := client.Get(apis.RealtimeClientAuthKey).(*core.Record)
989 if clientAuthRecord.Email() != customUser.Email {
990 t.Fatalf("Expected authRecord with email %q, got %q", customUser.Email, clientAuthRecord.Email())
991 }
992}
993
994// -------------------------------------------------------------------
995

Callers

nothing calls this directly

Calls 12

CleanupMethod · 0.95
SetMethod · 0.95
GetMethod · 0.95
NewTestAppFunction · 0.92
NewRouterFunction · 0.92
NewDefaultClientFunction · 0.92
findCustomUserByEmailFunction · 0.85
EmailMethod · 0.80
FindAuthRecordByEmailMethod · 0.65
SubscriptionsBrokerMethod · 0.65
SaveMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…