(t *testing.T)
| 955 | } |
| 956 | |
| 957 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…