(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestRedshiftSubscriptionBatchedPollingUser(t *testing.T) { |
| 52 | if dbType != "redshift" { |
| 53 | t.Skip("redshift-only test") |
| 54 | } |
| 55 | |
| 56 | if _, err := db.Exec(`UPDATE users SET phone = '555-redshift-initial' WHERE id = 1`); err != nil { |
| 57 | t.Fatal(err) |
| 58 | } |
| 59 | |
| 60 | gj, err := core.NewGraphJin(newConfig(&core.Config{ |
| 61 | DBType: "redshift", |
| 62 | DisableAllowList: true, |
| 63 | SubsPollDuration: 200 * time.Millisecond, |
| 64 | }), db) |
| 65 | if err != nil { |
| 66 | t.Fatal(err) |
| 67 | } |
| 68 | defer gj.Close() |
| 69 | |
| 70 | m, err := gj.Subscribe(context.Background(), ` |
| 71 | subscription redshift_user { |
| 72 | users(id: $id) { |
| 73 | id |
| 74 | |
| 75 | phone |
| 76 | } |
| 77 | }`, json.RawMessage(`{"id":1}`), nil) |
| 78 | if err != nil { |
| 79 | t.Fatal(err) |
| 80 | } |
| 81 | defer m.Unsubscribe() |
| 82 | |
| 83 | initial := waitRedshiftSubResult(t, m, 5*time.Second) |
| 84 | if !strings.Contains(initial.SQL(), `JSON_PARSE(?)`) || !strings.Contains(initial.SQL(), `UNNEST(_gj_sub_input._gj_params) WITH OFFSET`) { |
| 85 | t.Fatalf("redshift subscription did not use batched wrapper:\n%s", initial.SQL()) |
| 86 | } |
| 87 | if !bytes.Contains(initial.Data, []byte(`"email":"ada@example.com"`)) || |
| 88 | !bytes.Contains(initial.Data, []byte(`"phone":"555-redshift-initial"`)) { |
| 89 | t.Fatalf("unexpected initial subscription result: %s", initial.Data) |
| 90 | } |
| 91 | |
| 92 | assertNoRedshiftSubResult(t, m, 700*time.Millisecond) |
| 93 | |
| 94 | if _, err := db.Exec(`UPDATE users SET phone = '555-redshift-updated' WHERE id = 1`); err != nil { |
| 95 | t.Fatal(err) |
| 96 | } |
| 97 | changed := waitRedshiftSubResult(t, m, 5*time.Second) |
| 98 | if !bytes.Contains(changed.Data, []byte(`"phone":"555-redshift-updated"`)) { |
| 99 | t.Fatalf("unexpected changed subscription result: %s", changed.Data) |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | func TestRedshiftSubscriptionCursorBatchedPolling(t *testing.T) { |
| 104 | if dbType != "redshift" { |
nothing calls this directly
no test coverage detected