Home / File/ node-postgres.test.ts — drizzle-orm Source File

node-postgres.test.ts — drizzle-orm Source File

Architecture documentation for node-postgres.test.ts, a typescript file in the drizzle-orm codebase. 16 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  32b18a19_4daf_0590_6caf_6ed6c0bfce80["node-postgres.test.ts"]
  d133ab06_e39e_bce4_90ee_a55144ce75c2["pg-common.ts"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> d133ab06_e39e_bce4_90ee_a55144ce75c2
  a90d4692_a295_76b3_2a7a_9924864203ad["createDockerDB"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> a90d4692_a295_76b3_2a7a_9924864203ad
  d4e96821_5055_cb66_dd7b_f89dd0f8d0a0["tests"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> d4e96821_5055_cb66_dd7b_f89dd0f8d0a0
  7b6fdfe3_d9a8_26c3_430d_2261b1d7aadb["pg-common-cache.ts"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 7b6fdfe3_d9a8_26c3_430d_2261b1d7aadb
  76da0078_4d8f_9615_8689_c44d597d58dc["TestCache"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 76da0078_4d8f_9615_8689_c44d597d58dc
  d43d88d6_c6b6_386d_d59b_76b8db53bf29["TestGlobalCache"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> d43d88d6_c6b6_386d_d59b_76b8db53bf29
  a69d8fa0_a523_c055_3559_0193c74ef267["tests"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> a69d8fa0_a523_c055_3559_0193c74ef267
  cad5819d_2851_9c06_9778_62eb6e1b2dab["async-retry"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> cad5819d_2851_9c06_9778_62eb6e1b2dab
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  a59b228c_43d4_1772_d3df_66adbf678284["node-postgres"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> a59b228c_43d4_1772_d3df_66adbf678284
  5a4cd68c_6036_b967_0441_ccaa281af1be["migrator"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 5a4cd68c_6036_b967_0441_ccaa281af1be
  53497908_16e7_977d_e97d_7414884a88a6["pg-core"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 53497908_16e7_977d_e97d_7414884a88a6
  0d277acf_0d68_9daf_8724_642232a89719["pg"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 0d277acf_0d68_9daf_8724_642232a89719
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  32b18a19_4daf_0590_6caf_6ed6c0bfce80 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  style 32b18a19_4daf_0590_6caf_6ed6c0bfce80 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import retry from 'async-retry';
import { sql } from 'drizzle-orm';
import type { NodePgDatabase } from 'drizzle-orm/node-postgres';
import { drizzle } from 'drizzle-orm/node-postgres';
import { migrate } from 'drizzle-orm/node-postgres/migrator';
import { pgTable, serial, timestamp } from 'drizzle-orm/pg-core';
import { Client } from 'pg';
import { afterAll, beforeAll, beforeEach, expect, test } from 'vitest';
import { skipTests } from '~/common';
import { randomString } from '~/utils';
import { createDockerDB, tests, usersMigratorTable, usersTable } from './pg-common';
import { TestCache, TestGlobalCache, tests as cacheTests } from './pg-common-cache';

const ENABLE_LOGGING = false;

let db: NodePgDatabase;
let client: Client;
let dbGlobalCached: NodePgDatabase;
let cachedDb: NodePgDatabase;

beforeAll(async () => {
	let connectionString;
	if (process.env['PG_CONNECTION_STRING']) {
		connectionString = process.env['PG_CONNECTION_STRING'];
	} else {
		const { connectionString: conStr } = await createDockerDB();
		connectionString = conStr;
	}
	client = await retry(async () => {
		client = new Client(connectionString);
		await client.connect();
		return client;
	}, {
		retries: 20,
		factor: 1,
		minTimeout: 250,
		maxTimeout: 250,
		randomize: false,
		onRetry() {
			client?.end();
		},
	});
	db = drizzle(client, { logger: ENABLE_LOGGING });
	cachedDb = drizzle(client, { logger: ENABLE_LOGGING, cache: new TestCache() });
	dbGlobalCached = drizzle(client, { logger: ENABLE_LOGGING, cache: new TestGlobalCache() });
});

afterAll(async () => {
	await client?.end();
});

beforeEach((ctx) => {
	ctx.pg = {
		db,
	};
	ctx.cachedPg = {
		db: cachedDb,
		dbGlobalCached,
	};
});
// ... (433 more lines)

Domain

Dependencies

Frequently Asked Questions

What does node-postgres.test.ts do?
node-postgres.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does node-postgres.test.ts depend on?
node-postgres.test.ts imports 16 module(s): TestCache, TestGlobalCache, async-retry, common, createDockerDB, drizzle-orm, migrator, node-postgres, and 8 more.
Where is node-postgres.test.ts in the architecture?
node-postgres.test.ts is located at integration-tests/tests/pg/node-postgres.test.ts (domain: DrizzleORM, directory: integration-tests/tests/pg).

Analyze Your Own Codebase

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

Try Supermodel Free