-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,791 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { type StartedPostgreSqlContainer } from '@testcontainers/postgresql' | ||
import { type FastifyInstance } from 'fastify' | ||
import { afterAll, beforeAll, describe, expect, test } from 'vitest' | ||
|
||
import { startTestAppInstance, stopTestAppInstance } from './utils/fixtures' | ||
|
||
describe('GET /health route', () => { | ||
let container: StartedPostgreSqlContainer | ||
let app: FastifyInstance | ||
|
||
beforeAll(async () => { | ||
;({ container, app } = await startTestAppInstance()) | ||
}) | ||
|
||
afterAll(async () => { | ||
await stopTestAppInstance(container, app) | ||
}) | ||
|
||
test('should return success', async () => { | ||
const response = await app.inject({ | ||
method: 'GET', | ||
url: '/health', | ||
}) | ||
|
||
expect(response.statusCode).toBe(200) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { PostgreSqlContainer, type StartedPostgreSqlContainer } from '@testcontainers/postgresql' | ||
import type { FastifyInstance } from 'fastify' | ||
|
||
import { buildApp } from '@/app' | ||
|
||
export async function startTestAppInstance() { | ||
const container = await new PostgreSqlContainer().start() | ||
|
||
const app = await buildApp({ | ||
database: { | ||
connectionString: container.getConnectionUri(), | ||
}, | ||
app: { | ||
port: 8080, | ||
}, | ||
}) | ||
|
||
await app.ready() | ||
|
||
return { container, app } | ||
} | ||
|
||
export async function stopTestAppInstance(container: StartedPostgreSqlContainer, app: FastifyInstance) { | ||
await app?.close() | ||
await container?.stop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* eslint-disable import/no-unused-modules */ | ||
|
||
import tsconfigPaths from 'vite-tsconfig-paths' | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
plugins: [tsconfigPaths()], | ||
test: { | ||
hookTimeout: 50_000, | ||
coverage: { | ||
provider: 'istanbul', | ||
reporter: ['text', 'json-summary', 'json'], | ||
}, | ||
}, | ||
}) |
Oops, something went wrong.