Add import and use of Pool from pg
This commit is contained in:
1 parent
c7ee1ec01e
commit
9a476d9b86
1 file changed
+7
-2
@@ -1,5 +1,6 @@
|
|||||||
import { describe, it } from 'node:test';
|
import { describe, it } from 'node:test';
|
||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
import { Pool } from 'pg';
|
||||||
import { createCategoryRouter } from './category.router.ts';
|
import { createCategoryRouter } from './category.router.ts';
|
||||||
import { CategoryRepository } from './category.repository.ts';
|
import { CategoryRepository } from './category.repository.ts';
|
||||||
import { Request, Response } from 'express';
|
import { Request, Response } from 'express';
|
||||||
@@ -45,11 +46,15 @@ function getRouteHandler(router: any): Function {
|
|||||||
return routeLayer.route.stack[0].handle; // Target the primary callback handler array element
|
return routeLayer.route.stack[0].handle; // Target the primary callback handler array element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const pool = new Pool({
|
||||||
|
connectionString: process.env.DATABASE_URL || process.env.INTERNAL_PROD_DB_URL
|
||||||
|
});
|
||||||
|
|
||||||
describe('Category Router Endpoints', () => {
|
describe('Category Router Endpoints', () => {
|
||||||
|
|
||||||
it('GET /tree{/:path} - should return 200 and structural JSON array data on valid requests', async () => {
|
it('GET /tree{/:path} - should return 200 and structural JSON array data on valid requests', async () => {
|
||||||
const mockRepo = createMockRepository('success');
|
const mockRepo = createMockRepository('success');
|
||||||
const router = createCategoryRouter(mockRepo);
|
const router = createCategoryRouter(mockRepo, pool);
|
||||||
|
|
||||||
const mockReq = { params: { path: 'Top' } } as unknown as Request;
|
const mockReq = { params: { path: 'Top' } } as unknown as Request;
|
||||||
const { mockRes, data } = createMockResponse();
|
const { mockRes, data } = createMockResponse();
|
||||||
@@ -67,7 +72,7 @@ describe('Category Router Endpoints', () => {
|
|||||||
|
|
||||||
it('GET /tree{/:path} - should return 400 Bad Request if ltree path contains malformed formatting', async () => {
|
it('GET /tree{/:path} - should return 400 Bad Request if ltree path contains malformed formatting', async () => {
|
||||||
const mockRepo = createMockRepository('success');
|
const mockRepo = createMockRepository('success');
|
||||||
const router = createCategoryRouter(mockRepo);
|
const router = createCategoryRouter(mockRepo, pool);
|
||||||
|
|
||||||
const mockReq = { params: { path: 'Top.Bad Path!' } } as unknown as Request;
|
const mockReq = { params: { path: 'Top.Bad Path!' } } as unknown as Request;
|
||||||
const { mockRes, data } = createMockResponse();
|
const { mockRes, data } = createMockResponse();
|
||||||
|
|||||||
Reference in new issue
Block a user