Home / Function/ tests() — drizzle-orm Function Reference

tests() — drizzle-orm Function Reference

Architecture documentation for the tests() function in neon-http-batch.ts from the drizzle-orm codebase.

Entity Profile

Dependency Diagram

graph TD
  ee585e32_e282_6b50_1c46_f0cc53930dc3["tests()"]
  c7bc55e0_0d9e_c4da_8367_225284280736["neon-http-batch.ts"]
  ee585e32_e282_6b50_1c46_f0cc53930dc3 -->|defined in| c7bc55e0_0d9e_c4da_8367_225284280736
  style ee585e32_e282_6b50_1c46_f0cc53930dc3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

integration-tests/tests/pg/neon-http-batch.ts lines 139–556

export function tests() {
	describe('common', () => {
		beforeEach(async (ctx) => {
			const { db } = ctx.pg;
			await db.execute(sql`drop schema if exists public cascade`);
			await db.execute(sql`drop schema if exists mySchema cascade`);

			await db.execute(
				sql`
					create table users (
					    id serial primary key,
					    name text not null,
					    verified int not null default 0,
					    invited_by int references users(id)
					)
				`,
			);
			await db.execute(
				sql`
					create table groups (
					    id serial primary key,
					    name text not null,
					    description text
					)
				`,
			);
			await db.execute(
				sql`
					create table users_to_groups (
					    id serial,
					    user_id int not null references users(id),
					    group_id int not null references groups(id),
					    primary key (user_id, group_id)
					)
				`,
			);
			await db.execute(
				sql`
					create table posts (
					    id serial primary key,
					    content text not null,
					    owner_id int references users(id),
					    created_at timestamp not null default now()
					)
				`,
			);
			await db.execute(
				sql`
					create table comments (
					    id serial primary key,
					    content text not null,
					    creator int references users(id),
					    post_id int references posts(id),
					    created_at timestamp not null default now()
					)
				`,
			);
			await db.execute(
				sql`
					create table comment_likes (
					    id serial primary key,
					    creator int references users(id),
					    comment_id int references comments(id),
					    created_at timestamp not null default now()
					)
				`,
			);
		});

		test('batch api example', async (ctx) => {
			const { db } = ctx.neonPg;

			const batchResponse = await db.batch([
				db.insert(usersTable).values({ id: 1, name: 'John' }).returning({
					id: usersTable.id,
					invitedBy: usersTable.invitedBy,
				}),
				db.insert(usersTable).values({ id: 2, name: 'Dan' }),
				db.select().from(usersTable),
			]);

Domain

Subdomains

Frequently Asked Questions

What does tests() do?
tests() is a function in the drizzle-orm codebase, defined in integration-tests/tests/pg/neon-http-batch.ts.
Where is tests() defined?
tests() is defined in integration-tests/tests/pg/neon-http-batch.ts at line 139.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free