Skip to content

Commit

Permalink
chore(typeorm): cleanup adapter testing files (#10833)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed May 9, 2024
1 parent 8751fa4 commit 5136b3f
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 87 deletions.
Expand Up @@ -18,7 +18,6 @@ echo "Waiting 10s for db to start..." && sleep 10

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

if vitest run -c ../utils/vitest.config.ts ./test/mysql-multi-project-schema/index.test.ts; then
Expand Down
Expand Up @@ -21,7 +21,6 @@ echo "Waiting 5s for db to start..." && sleep 5

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

if vitest run -c ../utils/vitest.config.ts ./test/pg-multi-project-schema/index.test.ts; then
Expand Down
1 change: 0 additions & 1 deletion packages/adapter-drizzle/test/pg/test.sh
Expand Up @@ -21,7 +21,6 @@ echo "Waiting 5s for db to start..." && sleep 5

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

if vitest run -c ../utils/vitest.config.ts ./test/pg/index.test.ts; then
Expand Down
3 changes: 0 additions & 3 deletions packages/adapter-drizzle/test/sqlite/test.sh
Expand Up @@ -7,11 +7,8 @@ echo "Running SQLite tests."
rm -f db.sqlite

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

vitest run -c ../utils/vitest.config.ts ./test/sqlite/index.test.ts

if vitest run -c ../utils/vitest.config.ts ./test/sqlite/index.test.ts; then
rm -f db.sqlite
else
Expand Down
10 changes: 4 additions & 6 deletions packages/adapter-typeorm/package.json
Expand Up @@ -39,12 +39,10 @@
"build": "tsc",
"dev": "tsc -w",
"clean": "rm -rf dist",
"init:db": "test/init.sh",
"mysql": "pnpm init:db && test/mysql/test.sh",
"postgres": "pnpm init:db && test/postgresql/test.sh",
"sqlite": "test/sqlite/test.sh",
"test:containers": "test/test.sh",
"test": "test/test.sh"
"test": "pnpm test:mysql && pnpm test:sqlite && pnpm test:pg",
"test:mysql": "pnpm clean && ./test/mysql/test.sh",
"test:pg": "pnpm clean && ./test/postgresql/test.sh",
"test:sqlite": "pnpm clean && ./test/sqlite/test.sh"
},
"dependencies": {
"@auth/core": "workspace:*"
Expand Down
30 changes: 0 additions & 30 deletions packages/adapter-typeorm/test/init.sh

This file was deleted.

34 changes: 30 additions & 4 deletions packages/adapter-typeorm/test/mysql/test.sh
@@ -1,13 +1,39 @@
#!/usr/bin/env bash
set -eu

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

MYSQL_DATABASE=next-auth
MYSQL_ROOT_PASSWORD=password
MYSQL_CONTAINER_NAME=next-auth-mysql-test

function startDatabase {
docker run -d --rm \
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
--name "${MYSQL_CONTAINER_NAME}" \
-p 3306:3306 \
mysql:8 --default-authentication-plugin=mysql_native_password

echo "Waiting 5s for db to start..."
sleep 5
}

startDatabase
echo "Started running MySQL tests with default models."
vitest run -c ../utils/vitest.config.ts mysql/index.test.ts
if vitest run -c ../utils/vitest.config.ts mysql/index.test.ts; then
docker stop ${MYSQL_CONTAINER_NAME}
else
docker stop ${MYSQL_CONTAINER_NAME} && exit 1
fi
echo "Finished running MySQL tests with default models."

startDatabase
echo "Started running MySQL tests with custom models."
CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts mysql/index.custom.test.ts
if CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts mysql/index.custom.test.ts; then
docker stop ${MYSQL_CONTAINER_NAME}
else
docker stop ${MYSQL_CONTAINER_NAME} && exit 1
fi
echo "Finished running MySQL tests with custom models."
35 changes: 31 additions & 4 deletions packages/adapter-typeorm/test/postgresql/test.sh
@@ -1,13 +1,40 @@
#!/usr/bin/env bash
set -eu

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

PGUSER=nextauth
PGDATABASE=nextauth
PG_CONTAINER_NAME=next-auth-postgres-test

function startDatabase {
docker run -d --rm \
-e POSTGRES_USER=${PGUSER} \
-e POSTGRES_DB=${PGDATABASE} \
-e POSTGRES_HOST_AUTH_METHOD=trust \
--name "${PG_CONTAINER_NAME}" \
-p 5432:5432 \
postgres:13.3

echo "Waiting 5s for db to start..."
sleep 5
}

startDatabase
echo "Started running PostgreSQL tests with default models."
vitest run -c ../utils/vitest.config.ts postgresql/index.test.ts
if vitest run -c ../utils/vitest.config.ts postgresql/index.test.ts; then
docker stop ${PG_CONTAINER_NAME}
else
docker stop ${PG_CONTAINER_NAME} && exit 1
fi
echo "Finished running PostgreSQL tests with default models."

startDatabase
echo "Started running PostgreSQL tests with custom models."
CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts postgresql/index.custom.test.ts
if CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts postgresql/index.custom.test.ts; then
docker stop ${PG_CONTAINER_NAME}
else
docker stop ${PG_CONTAINER_NAME} && exit 1
fi
echo "Finished running PostgreSQL tests with custom models."
14 changes: 12 additions & 2 deletions packages/adapter-typeorm/test/sqlite/test.sh
Expand Up @@ -4,11 +4,21 @@ set -eu
rm -f test/sqlite/dev.db

echo "Started running SQLite tests with default models."
vitest run -c ../utils/vitest.config.ts sqlite/index.test.ts
if vitest run -c ../utils/vitest.config.ts sqlite/index.test.ts; then
rm -f db.sqlite
else
rm -f db.sqlite && exit 1
fi
echo "Finished running SQLite tests with default models."

rm -f test/sqlite/dev.db

echo "Started running SQLite tests with custom models."
CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts sqlite/index.custom.test.ts
if CUSTOM_MODEL=1 vitest run -c ../utils/vitest.config.ts sqlite/index.custom.test.ts; then
rm -f db.sqlite
else
rm -f db.sqlite && exit 1
fi
echo "Finished running SQLite tests with custom models."

rm -f test/sqlite/dev.db
35 changes: 0 additions & 35 deletions packages/adapter-typeorm/test/test.sh

This file was deleted.

0 comments on commit 5136b3f

Please sign in to comment.