Home / File/ neon-http.test.ts — drizzle-orm Source File

neon-http.test.ts — drizzle-orm Source File

Architecture documentation for neon-http.test.ts, a typescript file in the drizzle-orm codebase. 14 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  d27467f0_72cf_286d_a537_902fcaa2eddb["neon-http.test.ts"]
  d133ab06_e39e_bce4_90ee_a55144ce75c2["pg-common.ts"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> d133ab06_e39e_bce4_90ee_a55144ce75c2
  d4e96821_5055_cb66_dd7b_f89dd0f8d0a0["tests"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> d4e96821_5055_cb66_dd7b_f89dd0f8d0a0
  7b6fdfe3_d9a8_26c3_430d_2261b1d7aadb["pg-common-cache.ts"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 7b6fdfe3_d9a8_26c3_430d_2261b1d7aadb
  76da0078_4d8f_9615_8689_c44d597d58dc["TestCache"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 76da0078_4d8f_9615_8689_c44d597d58dc
  d43d88d6_c6b6_386d_d59b_76b8db53bf29["TestGlobalCache"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> d43d88d6_c6b6_386d_d59b_76b8db53bf29
  a69d8fa0_a523_c055_3559_0193c74ef267["tests"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> a69d8fa0_a523_c055_3559_0193c74ef267
  e9867962_df5d_03c5_8e49_973b2b1a930a["serverless"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> e9867962_df5d_03c5_8e49_973b2b1a930a
  690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031
  7a947e11_4b82_a72e_a266_e039a8bd3ff1["neon-http"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 7a947e11_4b82_a72e_a266_e039a8bd3ff1
  dc92569c_6991_f402_2d06_12801eeb8a5e["migrator"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> dc92569c_6991_f402_2d06_12801eeb8a5e
  53497908_16e7_977d_e97d_7414884a88a6["pg-core"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 53497908_16e7_977d_e97d_7414884a88a6
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  5536e6a8_02de_67a7_6eaf_0fd73c9c2d92["common"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> 5536e6a8_02de_67a7_6eaf_0fd73c9c2d92
  be4f1824_b255_ba95_9daf_35a679c997bf["utils"]
  d27467f0_72cf_286d_a537_902fcaa2eddb --> be4f1824_b255_ba95_9daf_35a679c997bf
  style d27467f0_72cf_286d_a537_902fcaa2eddb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { neon, neonConfig, type NeonQueryFunction } from '@neondatabase/serverless';
import { eq, sql } from 'drizzle-orm';
import { drizzle, type NeonHttpDatabase } from 'drizzle-orm/neon-http';
import { migrate } from 'drizzle-orm/neon-http/migrator';
import { pgMaterializedView, pgTable, serial, timestamp } from 'drizzle-orm/pg-core';
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
import { skipTests } from '~/common';
import { randomString } from '~/utils';
import { tests, usersMigratorTable, usersTable } from './pg-common';
import { TestCache, TestGlobalCache, tests as cacheTests } from './pg-common-cache';

const ENABLE_LOGGING = false;

let db: NeonHttpDatabase;
let dbGlobalCached: NeonHttpDatabase;
let cachedDb: NeonHttpDatabase;

beforeAll(async () => {
	const connectionString = process.env['NEON_HTTP_CONNECTION_STRING'];
	if (!connectionString) {
		throw new Error('NEON_CONNECTION_STRING is not defined');
	}

	neonConfig.fetchEndpoint = (host) => {
		const [protocol, port] = host === 'db.localtest.me' ? ['http', 4444] : ['https', 443];
		return `${protocol}://${host}:${port}/sql`;
	};
	const client = neon(connectionString);
	db = drizzle(client, { logger: ENABLE_LOGGING });
	cachedDb = drizzle(client, {
		logger: ENABLE_LOGGING,
		cache: new TestCache(),
	});
	dbGlobalCached = drizzle(client, {
		logger: ENABLE_LOGGING,
		cache: new TestGlobalCache(),
	});
});

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

test('migrator : default migration strategy', async () => {
	await db.execute(sql`drop table if exists all_columns`);
	await db.execute(sql`drop table if exists users12`);
	await db.execute(sql`drop table if exists "drizzle"."__drizzle_migrations"`);

	await migrate(db, { migrationsFolder: './drizzle2/pg' });

	await db.insert(usersMigratorTable).values({ name: 'John', email: 'email' });

	const result = await db.select().from(usersMigratorTable);

// ... (730 more lines)

Domain

Dependencies

Frequently Asked Questions

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