Skip to content

Commit

Permalink
Replace tsx with ts-node for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dankochetov committed May 26, 2024
1 parent 410f881 commit 53b9b57
Show file tree
Hide file tree
Showing 20 changed files with 184 additions and 49 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ dist.new
.rollup.cache
dist-dts
rollup.config-*.mjs
*.log
.DS_Store
3 changes: 1 addition & 2 deletions drizzle-orm/src/pg-core/schema.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { entityKind, is } from '~/entity.ts';
import type { SQLWrapper } from '~/index.ts';
import { SQL, sql } from '~/index.ts';
import { SQL, sql, type SQLWrapper } from '~/sql/sql.ts';
import type { pgEnum } from './columns/enum.ts';
import { pgEnumWithSchema } from './columns/enum.ts';
import { type PgTableFn, pgTableWithSchema } from './table.ts';
Expand Down
2 changes: 1 addition & 1 deletion drizzle-typebox/tests/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
year,
} from 'drizzle-orm/mysql-core';
import { createInsertSchema, createSelectSchema, jsonSchema } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

const customInt = customType<{ data: number }>({
dataType() {
Expand Down
2 changes: 1 addition & 1 deletion drizzle-typebox/tests/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Value } from '@sinclair/typebox/value';
import test from 'ava';
import { char, date, integer, pgEnum, pgTable, serial, text, timestamp, varchar } from 'drizzle-orm/pg-core';
import { createInsertSchema, createSelectSchema, Nullable } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

export const roleEnum = pgEnum('role', ['admin', 'user']);

Expand Down
2 changes: 1 addition & 1 deletion drizzle-typebox/tests/sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Value } from '@sinclair/typebox/value';
import test from 'ava';
import { blob, integer, numeric, real, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { createInsertSchema, createSelectSchema, jsonSchema, Nullable } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

const blobJsonSchema = Type.Object({
foo: Type.String(),
Expand Down
2 changes: 1 addition & 1 deletion drizzle-valibot/tests/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
string,
} from 'valibot';
import { createInsertSchema, createSelectSchema, jsonSchema } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

const customInt = customType<{ data: number }>({
dataType() {
Expand Down
2 changes: 1 addition & 1 deletion drizzle-valibot/tests/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
string,
} from 'valibot';
import { createInsertSchema, createSelectSchema } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

export const roleEnum = pgEnum('role', ['admin', 'user']);

Expand Down
2 changes: 1 addition & 1 deletion drizzle-valibot/tests/sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
string,
} from 'valibot';
import { createInsertSchema, createSelectSchema, jsonSchema } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

const blobJsonSchema = object({
foo: string(),
Expand Down
2 changes: 1 addition & 1 deletion drizzle-zod/tests/mysql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
} from 'drizzle-orm/mysql-core';
import { z } from 'zod';
import { createInsertSchema, createSelectSchema, jsonSchema } from '~/index';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

const customInt = customType<{ data: number }>({
dataType() {
Expand Down
2 changes: 1 addition & 1 deletion drizzle-zod/tests/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava';
import { char, date, integer, pgEnum, pgTable, serial, text, timestamp, varchar } from 'drizzle-orm/pg-core';
import { z } from 'zod';
import { createInsertSchema, createSelectSchema } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

export const roleEnum = pgEnum('role', ['admin', 'user']);

Expand Down
2 changes: 1 addition & 1 deletion drizzle-zod/tests/sqlite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava';
import { blob, integer, numeric, real, sqliteTable, text } from 'drizzle-orm/sqlite-core';
import { z } from 'zod';
import { createInsertSchema, createSelectSchema, jsonSchema } from '../src';
import { expectSchemaShape } from './utils';
import { expectSchemaShape } from './utils.ts';

const blobJsonSchema = z.object({
foo: z.string(),
Expand Down
12 changes: 6 additions & 6 deletions integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"test:types": "tsc",
"test": "pnpm test:ava && pnpm test:esm && pnpm test:rqb",
"test:ava": "NODE_OPTIONS='--loader=tsx --no-warnings --max-old-space-size=8192' ava tests --timeout=60s --serial",
"test:ava": "cross-env NODE_OPTIONS='--loader=ts-node/esm --no-warnings' ava tests --timeout=60s --serial",
"test:rqb": "vitest run --poolOptions.threads.singleThread",
"test:esm": "node tests/imports.test.mjs && node tests/imports.test.cjs",
"test:data-api": "sst shell vitest run tests/awsdatapi.test.ts"
Expand Down Expand Up @@ -34,19 +34,16 @@
],
"extensions": {
"ts": "module"
},
"nodeArguments": [
"--loader=tsx"
]
}
},
"keywords": [],
"author": "Drizzle Team",
"license": "Apache-2.0",
"private": true,
"devDependencies": {
"@ava/typescript": "^5.0.0",
"@neondatabase/serverless": "0.9.0",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@types/axios": "^0.14.0",
"@types/better-sqlite3": "^7.6.4",
"@types/dockerode": "^3.3.18",
"@types/express": "^4.17.16",
Expand All @@ -57,6 +54,8 @@
"@vitest/ui": "^1.6.0",
"ava": "^5.3.0",
"axios": "^1.4.0",
"cross-env": "^7.0.3",
"ts-node": "^10.9.2",
"vite": "^4.3.9",
"vite-tsconfig-paths": "^4.2.0",
"zx": "^7.2.2"
Expand All @@ -83,6 +82,7 @@
"mysql2": "^3.3.3",
"pg": "^8.11.0",
"postgres": "^3.3.5",
"segfault-handler": "^1.3.0",
"source-map-support": "^0.5.21",
"sql.js": "^1.8.0",
"sqlite3": "^5.1.4",
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/segfault.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import SegfaultHandler from 'segfault-handler';
SegfaultHandler.registerHandler();
4 changes: 2 additions & 2 deletions integration-tests/tests/awsdatapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
import { Resource } from 'sst';
import { afterAll, beforeAll, beforeEach, expect, expectTypeOf, test } from 'vitest';

import type { Equal } from './utils';
import { Expect, randomString } from './utils';
import type { Equal } from './utils.ts';
import { Expect, randomString } from './utils.ts';

dotenv.config();

Expand Down
9 changes: 5 additions & 4 deletions integration-tests/tests/mysql-schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dotenv/config';
import type { TestFn } from 'ava';
import anyTest from 'ava';
import Docker from 'dockerode';
import { asc, eq, Name, placeholder, sql } from 'drizzle-orm';
import { asc, eq, Name, sql } from 'drizzle-orm';
import {
alias,
boolean,
Expand All @@ -27,7 +27,8 @@ import { drizzle } from 'drizzle-orm/mysql2';
import getPort from 'get-port';
import * as mysql from 'mysql2/promise';
import { v4 as uuid } from 'uuid';
import { toLocalDate } from './utils';

import { toLocalDate } from './utils.ts';

const mySchema = mysqlSchema('mySchema');

Expand Down Expand Up @@ -660,7 +661,7 @@ test.serial('prepared statement reuse', async (t) => {

const stmt = db.insert(usersTable).values({
verified: true,
name: placeholder('name'),
name: sql.placeholder('name'),
}).prepare();

for (let i = 0; i < 10; i++) {
Expand Down Expand Up @@ -695,7 +696,7 @@ test.serial('prepared statement with placeholder in .where', async (t) => {
id: usersTable.id,
name: usersTable.name,
}).from(usersTable)
.where(eq(usersTable.id, placeholder('id')))
.where(eq(usersTable.id, sql.placeholder('id')))
.prepare();
const result = await stmt.execute({ id: 1 });

Expand Down
3 changes: 2 additions & 1 deletion integration-tests/tests/mysql.custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import { migrate } from 'drizzle-orm/mysql2/migrator';
import getPort from 'get-port';
import * as mysql from 'mysql2/promise';
import { v4 as uuid } from 'uuid';
import { toLocalDate } from './utils';

import { toLocalDate } from './utils.ts';

const customSerial = customType<{ data: number; notNull: true; default: true }>({
dataType() {
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/pg.custom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { alias, customType, pgTable, pgTableCreator, serial, text } from 'drizzl
import getPort from 'get-port';
import pg from 'pg';
import { v4 as uuid } from 'uuid';
import { randomString } from './utils';
import { randomString } from './utils.ts';

const { Client } = pg;

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ import { type Equal, Expect, randomString } from './utils.ts';

const { Client } = pg;

const ENABLE_LOGGING = true;
const ENABLE_LOGGING = false;

const usersTable = pgTable('users', {
id: serial('id' as string).primaryKey(),
Expand Down
1 change: 1 addition & 0 deletions integration-tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"checkJs": false,
"noEmit": true,
"paths": {
"~/*": ["./tests/*"]
Expand Down
Loading

0 comments on commit 53b9b57

Please sign in to comment.