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

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

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

Entity Profile

Dependency Diagram

graph LR
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd["postgres-js.test.ts"]
  d133ab06_e39e_bce4_90ee_a55144ce75c2["pg-common.ts"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> d133ab06_e39e_bce4_90ee_a55144ce75c2
  a90d4692_a295_76b3_2a7a_9924864203ad["createDockerDB"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> a90d4692_a295_76b3_2a7a_9924864203ad
  d4e96821_5055_cb66_dd7b_f89dd0f8d0a0["tests"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> d4e96821_5055_cb66_dd7b_f89dd0f8d0a0
  7b6fdfe3_d9a8_26c3_430d_2261b1d7aadb["pg-common-cache.ts"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 7b6fdfe3_d9a8_26c3_430d_2261b1d7aadb
  76da0078_4d8f_9615_8689_c44d597d58dc["TestCache"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 76da0078_4d8f_9615_8689_c44d597d58dc
  d43d88d6_c6b6_386d_d59b_76b8db53bf29["TestGlobalCache"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> d43d88d6_c6b6_386d_d59b_76b8db53bf29
  a69d8fa0_a523_c055_3559_0193c74ef267["tests"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> a69d8fa0_a523_c055_3559_0193c74ef267
  cad5819d_2851_9c06_9778_62eb6e1b2dab["async-retry"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> cad5819d_2851_9c06_9778_62eb6e1b2dab
  abdb41ef_bca7_fd22_4985_3715de398926["postgres-js"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> abdb41ef_bca7_fd22_4985_3715de398926
  07445d0e_3235_2bb0_78cf_fa72a47ceb7f["postgres"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 07445d0e_3235_2bb0_78cf_fa72a47ceb7f
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  53497908_16e7_977d_e97d_7414884a88a6["pg-core"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 53497908_16e7_977d_e97d_7414884a88a6
  70bd1c85_02dd_90fd_638d_2a0101a88223["migrator"]
  8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd --> 70bd1c85_02dd_90fd_638d_2a0101a88223
  style 8a70bea6_7c17_bc4e_0a1f_e2a09c3304fd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import retry from 'async-retry';
import type { PostgresJsDatabase } from 'drizzle-orm/postgres-js';
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres, { type Sql } from 'postgres';
import { afterAll, beforeAll, beforeEach, expect, test } from 'vitest';

import { Name, sql } from 'drizzle-orm';
import { pgTable, serial, timestamp } from 'drizzle-orm/pg-core';
import { migrate } from 'drizzle-orm/postgres-js/migrator';
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: PostgresJsDatabase;
let dbGlobalCached: PostgresJsDatabase;
let cachedDb: PostgresJsDatabase;
let client: Sql;

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 = postgres(connectionString, {
			max: 1,
			onnotice: () => {
				// disable notices
			},
		});
		await client`select 1`;
		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,
// ... (431 more lines)

Domain

Dependencies

Frequently Asked Questions

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