Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2import { env } from 'cloudflare:test'
3import { eq } from 'drizzle-orm'
4
5import { getDb } from '#/db/index.ts'
6import { providers } from '#/db/schema.ts'
7
8describe('read path', () => {
9 it('a replica session reads a row written on the primary', async () => {
10 const primary = getDb(env)
11 await primary
12 .insert(providers)
13 .values({
14 id: 'read-path-replica',
15 displayName: 'Replica',
16 specSourceUrl: 'https://example.com/spec',
17 })
18 .onConflictDoNothing()
19 const replica = getDb(env, { replica: true })
20 const row = await replica.query.providers.findFirst({
21 where: eq(providers.id, 'read-path-replica'),
22 })
23 expect(row?.displayName).toBe('Replica')
24 })
25})