Skip to content

Commit

Permalink
Can we create the database from the command line?
Browse files Browse the repository at this point in the history
  • Loading branch information
Carifio24 committed Sep 29, 2024
1 parent d763336 commit b1a2c72
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,19 @@ jobs:
- name: Start MySQL service
run: sudo systemctl start mysql.service

- name: Create database
run: |
echo "CREATE DATABASE IF NOT EXISTS test" > setup.sql
sudo mysql -h 127.0.0.1 -uroot -proot < setup.sql
- name: Test
env:
TEST_DB_HOSTNAME: ${{ secrets.TEST_DB_HOSTNAME }}
TEST_DB_USERNAME: ${{ secrets.TEST_DB_USERNAME }}
TEST_DB_PASSWORD: ${{ secrets.TEST_DB_PASSWORD }}
run: npm run test

- name: Destroy test database
run: |
echo "DROP DATABASE test" > teardown.sql
sudo mysql -h 127.0.0.1 -uroot -proot < teardown.sql
4 changes: 2 additions & 2 deletions tests/root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ beforeAll(async () => {
}, 100_000);

afterAll(async () => {
const conn = await createMySQLConnection();
await conn.query("DROP DATABASE test;");
// const conn = await createMySQLConnection();
// await conn.query("DROP DATABASE test;");
});

describe("Test root route", () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export async function setupTestDatabase(): Promise<Sequelize> {
config();
const username = process.env.TEST_DB_USERNAME as string;
const password = process.env.TEST_DB_PASSWORD as string;
const connection = await createMySQLConnection();
await connection.query("CREATE DATABASE IF NOT EXISTS test;");
// const connection = await createMySQLConnection();
// await connection.query("CREATE DATABASE IF NOT EXISTS test;");
const db = getDatabaseConnection({
dbName: "test",
username,
Expand Down

0 comments on commit b1a2c72

Please sign in to comment.