Created
December 5, 2022 17:05
-
-
Save pigoz/009ea247aebdef3557a42017e4614757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const pool = (name: string, self: DbTest) => { | |
return it(name, async () => { | |
return await zdb.serializable(pgpool, async conn => { | |
await self(conn); | |
await zdb.sql`ROLLBACK`.run(conn); | |
}); | |
}); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { it, describe, expect } from './helpers'; | |
import { deletePost, getPosts, createPostTwice } from '~/domain/posts'; | |
describe.concurrent('posts', () => { | |
it.pool('returns two values', async conn => { | |
const posts = await getPosts(conn); | |
expect(posts.length).toEqual(2); | |
}); | |
it.pool('deletes one post', async conn => { | |
const posts = await getPosts(conn); | |
await deletePost(posts[0].id, conn); | |
expect((await getPosts(conn)).length).toEqual(1); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment