Home / File/ singlestore.test.ts — drizzle-orm Source File

singlestore.test.ts — drizzle-orm Source File

Architecture documentation for singlestore.test.ts, a typescript file in the drizzle-orm codebase. 11 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  f8cac0b9_5170_b142_659b_035baf0c8931["singlestore.test.ts"]
  366a8840_7045_c01f_5bc2_0e3563a812f0["singlestore-cache.ts"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 366a8840_7045_c01f_5bc2_0e3563a812f0
  0f7bfc13_f028_d9da_933e_420fccb387ca["TestCache"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 0f7bfc13_f028_d9da_933e_420fccb387ca
  58fc1702_28d9_32ba_a090_d4044bb1b841["TestGlobalCache"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 58fc1702_28d9_32ba_a090_d4044bb1b841
  9e6ad3a7_9dcb_b1d4_3392_962710879b70["tests"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 9e6ad3a7_9dcb_b1d4_3392_962710879b70
  f934c582_f266_1cbe_5ff9_08bc5f148179["singlestore-common.ts"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> f934c582_f266_1cbe_5ff9_08bc5f148179
  e6761147_9bb8_212e_229c_68c58cc58851["createDockerDB"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> e6761147_9bb8_212e_229c_68c58cc58851
  850f4c00_692c_1d88_ade9_69e3d5af9d75["tests"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 850f4c00_692c_1d88_ade9_69e3d5af9d75
  cad5819d_2851_9c06_9778_62eb6e1b2dab["async-retry"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> cad5819d_2851_9c06_9778_62eb6e1b2dab
  11dc3ec3_3c65_f9a0_8c8d_09bc214bc70d["singlestore"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 11dc3ec3_3c65_f9a0_8c8d_09bc214bc70d
  a340f455_7575_91f4_791a_10cd9b9dba1a["promise"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> a340f455_7575_91f4_791a_10cd9b9dba1a
  8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"]
  f8cac0b9_5170_b142_659b_035baf0c8931 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686
  style f8cac0b9_5170_b142_659b_035baf0c8931 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import retry from 'async-retry';
import { drizzle } from 'drizzle-orm/singlestore';
import type { SingleStoreDriverDatabase } from 'drizzle-orm/singlestore';
import * as mysql2 from 'mysql2/promise';
import { afterAll, beforeAll, beforeEach } from 'vitest';
import { TestCache, TestGlobalCache, tests as cacheTests } from './singlestore-cache';
import { createDockerDB, tests } from './singlestore-common';

const ENABLE_LOGGING = false;

let db: SingleStoreDriverDatabase;
let dbGlobalCached: SingleStoreDriverDatabase;
let cachedDb: SingleStoreDriverDatabase;
let client: mysql2.Connection;

beforeAll(async () => {
	let connectionString;
	if (process.env['SINGLESTORE_CONNECTION_STRING']) {
		connectionString = process.env['SINGLESTORE_CONNECTION_STRING'];
	} else {
		const { connectionString: conStr } = await createDockerDB();
		connectionString = conStr;
	}
	client = await retry(async () => {
		client = await mysql2.createConnection({ uri: connectionString, supportBigNumbers: true });
		await client.connect();
		return client;
	}, {
		retries: 20,
		factor: 1,
		minTimeout: 250,
		maxTimeout: 250,
		randomize: false,
		onRetry() {
			client?.end();
		},
	});

	await client.query(`CREATE DATABASE IF NOT EXISTS drizzle;`);
	await client.changeUser({ database: 'drizzle' });
	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.singlestore = {
		db,
	};
	ctx.cachedSingleStore = {
		db: cachedDb,
		dbGlobalCached,
	};
});

cacheTests();
tests();

Domain

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free