Skip to content

Commit 5136b3f

Browse files
authored
chore(typeorm): cleanup adapter testing files (#10833)
1 parent 8751fa4 commit 5136b3f

File tree

10 files changed

+77
-87
lines changed

10 files changed

+77
-87
lines changed

packages/adapter-drizzle/test/mysql-multi-project-schema/test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ echo "Waiting 10s for db to start..." && sleep 10
1818

1919
# Push schema and seed
2020
drizzle-kit generate:mysql --config=./test/mysql-multi-project-schema/drizzle.config.ts
21-
NODE_OPTIONS='--import tsx'
2221
tsx ./test/mysql-multi-project-schema/migrator.ts
2322

2423
if vitest run -c ../utils/vitest.config.ts ./test/mysql-multi-project-schema/index.test.ts; then

packages/adapter-drizzle/test/pg-multi-project-schema/test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ echo "Waiting 5s for db to start..." && sleep 5
2121

2222
# Push schema and seed
2323
drizzle-kit generate:pg --config=./test/pg-multi-project-schema/drizzle.config.ts
24-
NODE_OPTIONS='--import tsx'
2524
tsx ./test/pg-multi-project-schema/migrator.ts
2625

2726
if vitest run -c ../utils/vitest.config.ts ./test/pg-multi-project-schema/index.test.ts; then

packages/adapter-drizzle/test/pg/test.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ echo "Waiting 5s for db to start..." && sleep 5
2121

2222
# Push schema and seed
2323
drizzle-kit generate:pg --config=./test/pg/drizzle.config.ts
24-
NODE_OPTIONS='--import tsx'
2524
tsx ./test/pg/migrator.ts
2625

2726
if vitest run -c ../utils/vitest.config.ts ./test/pg/index.test.ts; then

packages/adapter-drizzle/test/sqlite/test.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ echo "Running SQLite tests."
77
rm -f db.sqlite
88

99
drizzle-kit generate:sqlite --config=./test/sqlite/drizzle.config.ts
10-
NODE_OPTIONS='--import tsx'
1110
tsx ./test/sqlite/migrator.ts
1211

13-
vitest run -c ../utils/vitest.config.ts ./test/sqlite/index.test.ts
14-
1512
if vitest run -c ../utils/vitest.config.ts ./test/sqlite/index.test.ts; then
1613
rm -f db.sqlite
1714
else

packages/adapter-typeorm/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@
3939
"build": "tsc",
4040
"dev": "tsc -w",
4141
"clean": "rm -rf dist",
42-
"init:db": "test/init.sh",
43-
"mysql": "pnpm init:db && test/mysql/test.sh",
44-
"postgres": "pnpm init:db && test/postgresql/test.sh",
45-
"sqlite": "test/sqlite/test.sh",
46-
"test:containers": "test/test.sh",
47-
"test": "test/test.sh"
42+
"test": "pnpm test:mysql && pnpm test:sqlite && pnpm test:pg",
43+
"test:mysql": "pnpm clean && ./test/mysql/test.sh",
44+
"test:pg": "pnpm clean && ./test/postgresql/test.sh",
45+
"test:sqlite": "pnpm clean && ./test/sqlite/test.sh"
4846
},
4947
"dependencies": {
5048
"@auth/core": "workspace:*"

packages/adapter-typeorm/test/init.sh

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
#!/usr/bin/env bash
22
set -eu
33

4-
echo "Waiting 5s for db to start..."
5-
sleep 5
4+
# Init MySQL container
5+
echo "Initializing container for MySQL tests"
66

7+
MYSQL_DATABASE=next-auth
8+
MYSQL_ROOT_PASSWORD=password
9+
MYSQL_CONTAINER_NAME=next-auth-mysql-test
10+
11+
function startDatabase {
12+
docker run -d --rm \
13+
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
14+
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
15+
--name "${MYSQL_CONTAINER_NAME}" \
16+
-p 3306:3306 \
17+
mysql:8 --default-authentication-plugin=mysql_native_password
18+
19+
echo "Waiting 5s for db to start..."
20+
sleep 5
21+
}
22+
23+
startDatabase
724
echo "Started running MySQL tests with default models."
8-
vitest run -c ../utils/vitest.config.ts mysql/index.test.ts
25+
if vitest run -c ../utils/vitest.config.ts mysql/index.test.ts; then
26+
docker stop ${MYSQL_CONTAINER_NAME}
27+
else
28+
docker stop ${MYSQL_CONTAINER_NAME} && exit 1
29+
fi
930
echo "Finished running MySQL tests with default models."
1031

32+
startDatabase
1133
echo "Started running MySQL tests with custom models."
12-
CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts mysql/index.custom.test.ts
34+
if CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts mysql/index.custom.test.ts; then
35+
docker stop ${MYSQL_CONTAINER_NAME}
36+
else
37+
docker stop ${MYSQL_CONTAINER_NAME} && exit 1
38+
fi
1339
echo "Finished running MySQL tests with custom models."
Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,40 @@
11
#!/usr/bin/env bash
22
set -eu
33

4-
echo "Waiting 5s for db to start..."
5-
sleep 5
4+
# Init PostgreSQL container
5+
echo "Initializing container for PostgreSQL tests"
66

7+
PGUSER=nextauth
8+
PGDATABASE=nextauth
9+
PG_CONTAINER_NAME=next-auth-postgres-test
10+
11+
function startDatabase {
12+
docker run -d --rm \
13+
-e POSTGRES_USER=${PGUSER} \
14+
-e POSTGRES_DB=${PGDATABASE} \
15+
-e POSTGRES_HOST_AUTH_METHOD=trust \
16+
--name "${PG_CONTAINER_NAME}" \
17+
-p 5432:5432 \
18+
postgres:13.3
19+
20+
echo "Waiting 5s for db to start..."
21+
sleep 5
22+
}
23+
24+
startDatabase
725
echo "Started running PostgreSQL tests with default models."
8-
vitest run -c ../utils/vitest.config.ts postgresql/index.test.ts
26+
if vitest run -c ../utils/vitest.config.ts postgresql/index.test.ts; then
27+
docker stop ${PG_CONTAINER_NAME}
28+
else
29+
docker stop ${PG_CONTAINER_NAME} && exit 1
30+
fi
931
echo "Finished running PostgreSQL tests with default models."
1032

33+
startDatabase
1134
echo "Started running PostgreSQL tests with custom models."
12-
CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts postgresql/index.custom.test.ts
35+
if CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts postgresql/index.custom.test.ts; then
36+
docker stop ${PG_CONTAINER_NAME}
37+
else
38+
docker stop ${PG_CONTAINER_NAME} && exit 1
39+
fi
1340
echo "Finished running PostgreSQL tests with custom models."

packages/adapter-typeorm/test/sqlite/test.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,21 @@ set -eu
44
rm -f test/sqlite/dev.db
55

66
echo "Started running SQLite tests with default models."
7-
vitest run -c ../utils/vitest.config.ts sqlite/index.test.ts
7+
if vitest run -c ../utils/vitest.config.ts sqlite/index.test.ts; then
8+
rm -f db.sqlite
9+
else
10+
rm -f db.sqlite && exit 1
11+
fi
812
echo "Finished running SQLite tests with default models."
913

1014
rm -f test/sqlite/dev.db
1115

1216
echo "Started running SQLite tests with custom models."
13-
CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts sqlite/index.custom.test.ts
17+
if CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts sqlite/index.custom.test.ts; then
18+
rm -f db.sqlite
19+
else
20+
rm -f db.sqlite && exit 1
21+
fi
1422
echo "Finished running SQLite tests with custom models."
23+
24+
rm -f test/sqlite/dev.db

packages/adapter-typeorm/test/test.sh

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)