Skip to content

Instantly share code, notes, and snippets.

@pigoz
Created December 5, 2022 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pigoz/009ea247aebdef3557a42017e4614757 to your computer and use it in GitHub Desktop.
Save pigoz/009ea247aebdef3557a42017e4614757 to your computer and use it in GitHub Desktop.
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);
});
});
};
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