libsql-sqlite3.test.ts — drizzle-orm Source File
Architecture documentation for libsql-sqlite3.test.ts, a typescript file in the drizzle-orm codebase. 11 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f9dab37f_59e8_905c_2ec5_4cb9db2b53c4["libsql-sqlite3.test.ts"] 46ce8b0c_dd54_2020_c1e8_2865e4c5e575["sqlite-common.ts"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 46ce8b0c_dd54_2020_c1e8_2865e4c5e575 3418d3a3_df7d_8999_e21a_2b4339e5aa45["tests"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 3418d3a3_df7d_8999_e21a_2b4339e5aa45 51200908_c365_c84e_57b5_18d4c97284fd["sqlite3"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 51200908_c365_c84e_57b5_18d4c97284fd cad5819d_2851_9c06_9778_62eb6e1b2dab["async-retry"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> cad5819d_2851_9c06_9778_62eb6e1b2dab 690f7dfc_0aea_9ee8_d6e7_26bbb3689031["drizzle-orm"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 690f7dfc_0aea_9ee8_d6e7_26bbb3689031 28ab9394_054d_e176_bc32_0ec8b0808e2a["libsql"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 28ab9394_054d_e176_bc32_0ec8b0808e2a 7b1d67bb_d699_d5f9_a910_5776c48d8391["migrator"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 7b1d67bb_d699_d5f9_a910_5776c48d8391 97da3e1d_c09f_4ea3_7f67_b7da06284710["sqlite3"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 97da3e1d_c09f_4ea3_7f67_b7da06284710 8d35eaf2_a542_cfd4_fa1a_fafca0f02686["vitest"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 8d35eaf2_a542_cfd4_fa1a_fafca0f02686 5536e6a8_02de_67a7_6eaf_0fd73c9c2d92["common"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> 5536e6a8_02de_67a7_6eaf_0fd73c9c2d92 be4f1824_b255_ba95_9daf_35a679c997bf["utils"] f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 --> be4f1824_b255_ba95_9daf_35a679c997bf style f9dab37f_59e8_905c_2ec5_4cb9db2b53c4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { type Client, createClient } from '@libsql/client/sqlite3';
import retry from 'async-retry';
import { sql } from 'drizzle-orm';
import type { LibSQLDatabase } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';
import { drizzle } from 'drizzle-orm/libsql/sqlite3';
import { afterAll, beforeAll, beforeEach, expect, test } from 'vitest';
import { skipTests } from '~/common';
import { randomString } from '~/utils';
import { anotherUsersMigratorTable, tests, usersMigratorTable } from './sqlite-common';
const ENABLE_LOGGING = false;
let db: LibSQLDatabase;
let client: Client;
beforeAll(async () => {
const url = ':memory:';
client = await retry(async () => {
client = createClient({ url });
return client;
}, {
retries: 20,
factor: 1,
minTimeout: 250,
maxTimeout: 250,
randomize: false,
onRetry() {
client?.close();
},
});
db = drizzle(client, { logger: ENABLE_LOGGING });
});
afterAll(async () => {
client?.close();
});
beforeEach((ctx) => {
ctx.sqlite = {
db,
};
});
test('migrator', async () => {
await db.run(sql`drop table if exists another_users`);
await db.run(sql`drop table if exists users12`);
await db.run(sql`drop table if exists __drizzle_migrations`);
await migrate(db, { migrationsFolder: './drizzle2/sqlite' });
await db.insert(usersMigratorTable).values({ name: 'John', email: 'email' }).run();
const result = await db.select().from(usersMigratorTable).all();
await db.insert(anotherUsersMigratorTable).values({ name: 'John', email: 'email' }).run();
const result2 = await db.select().from(anotherUsersMigratorTable).all();
expect(result).toEqual([{ id: 1, name: 'John', email: 'email' }]);
expect(result2).toEqual([{ id: 1, name: 'John', email: 'email' }]);
await db.run(sql`drop table another_users`);
await db.run(sql`drop table users12`);
await db.run(sql`drop table __drizzle_migrations`);
});
test('migrator : migrate with custom table', async () => {
const customTable = randomString();
await db.run(sql`drop table if exists another_users`);
await db.run(sql`drop table if exists users12`);
await db.run(sql`drop table if exists ${sql.identifier(customTable)}`);
await migrate(db, { migrationsFolder: './drizzle2/sqlite', migrationsTable: customTable });
// test if the custom migrations table was created
const res = await db.all(sql`select * from ${sql.identifier(customTable)};`);
expect(res.length > 0).toBeTruthy();
// test if the migrated table are working as expected
await db.insert(usersMigratorTable).values({ name: 'John', email: 'email' });
const result = await db.select().from(usersMigratorTable);
expect(result).toEqual([{ id: 1, name: 'John', email: 'email' }]);
await db.run(sql`drop table another_users`);
await db.run(sql`drop table users12`);
await db.run(sql`drop table ${sql.identifier(customTable)}`);
});
skipTests([
'delete with limit and order by',
'update with limit and order by',
'transaction',
'transaction rollback',
'nested transaction',
'nested transaction rollback',
]);
tests();
Domain
Dependencies
- async-retry
- common
- drizzle-orm
- libsql
- migrator
- sqlite-common.ts
- sqlite3
- sqlite3
- tests
- utils
- vitest
Source
Frequently Asked Questions
What does libsql-sqlite3.test.ts do?
libsql-sqlite3.test.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleORM domain.
What does libsql-sqlite3.test.ts depend on?
libsql-sqlite3.test.ts imports 11 module(s): async-retry, common, drizzle-orm, libsql, migrator, sqlite-common.ts, sqlite3, sqlite3, and 3 more.
Where is libsql-sqlite3.test.ts in the architecture?
libsql-sqlite3.test.ts is located at integration-tests/tests/sqlite/libsql-sqlite3.test.ts (domain: DrizzleORM, directory: integration-tests/tests/sqlite).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free