(t *testing.T)
| 519 | } |
| 520 | |
| 521 | func 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 | |
| 560 | func TestRealtimeRecordHiddenFields(t *testing.T) { |
| 561 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…