Solucionado cierrre de pool para test
This commit is contained in:
@@ -4,7 +4,7 @@ import { SimController } from "./Sim.controller.js";
|
||||
import { EventBus } from "sim-shared/domain/EventBus.port.js";
|
||||
import { SimUseCases } from "./Sim.usecases.js";
|
||||
import { ConsumeMessage } from "amqplib";
|
||||
import { postgrClient } from "#config/postgreConfig.js";
|
||||
import { postgrClient, pgPool } from "#config/postgreConfig.js";
|
||||
import { httpInstance } from "#config/httpClient.config.js";
|
||||
import { OrderRepository } from "sim-shared/infrastructure/OrderRepository.js";
|
||||
import { PauseCancelTaskRepository } from "#adapters/PauseCancelTaskRepository.js";
|
||||
@@ -56,6 +56,10 @@ describe("SimController Integration Tests (Real UseCases)", () => {
|
||||
} as unknown as ConsumeMessage;
|
||||
};
|
||||
|
||||
after(async () => {
|
||||
await pgPool.end();
|
||||
});
|
||||
|
||||
describe("suspend", () => {
|
||||
it("should call stage_suspend and interact with DB and EventBus", async () => {
|
||||
const iccid = "test-iccid-suspend-" + Date.now();
|
||||
@@ -72,7 +76,6 @@ describe("SimController Integration Tests (Real UseCases)", () => {
|
||||
const handler = controller.suspend();
|
||||
await handler(msg);
|
||||
|
||||
console.log("Nack: ", eventBusMock.nack.mock.callCount())
|
||||
// Verify that it reached the stage_suspend logic (which adds to pauseRepository)
|
||||
// We can query the DB or check if ACK was called
|
||||
assert.strictEqual(eventBusMock.ack.mock.callCount(), 1, "Message should be ACKed on success");
|
||||
|
||||
@@ -185,7 +185,6 @@ export class SimController {
|
||||
}
|
||||
|
||||
const useCaseRes = await this.tryUseCase(msg, this.useCases.stage_suspend(suspendData))
|
||||
console.log("res::", useCaseRes)
|
||||
/*
|
||||
const res = await this.tryUseCase(msg, this.useCases.suspend(actionData))
|
||||
*/
|
||||
|
||||
@@ -285,9 +285,7 @@ export class SimUseCases {
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Preactivationdate", suspendData)
|
||||
const activationDate = await this.findActivationDate(suspendData)
|
||||
console.log("ActivationDate", activationDate)
|
||||
|
||||
const newTask: CreatePauseCancelTaskDTO = {
|
||||
iccid: iccid[0],
|
||||
|
||||
@@ -191,6 +191,8 @@ export class OrderRepository {
|
||||
const orderId = currentOrderResult.data?.id
|
||||
|
||||
if (orderId == undefined) {
|
||||
await client.query("ROLLBACK")
|
||||
client.release()
|
||||
return {
|
||||
error: "El order a actualizar no existe " + idType + ": " + idValue
|
||||
}
|
||||
@@ -261,7 +263,6 @@ export class OrderRepository {
|
||||
return updatedOrder
|
||||
}
|
||||
|
||||
|
||||
public async finishOrder(args: FinishOrderDTO) {
|
||||
const client = await this.pgClient.connect();
|
||||
assert((args.id != undefined) != (args.correlation_id != undefined))
|
||||
@@ -281,6 +282,8 @@ export class OrderRepository {
|
||||
const orderId = currentOrderResult.data?.id
|
||||
|
||||
if (orderId == undefined) {
|
||||
await client.query("ROLLBACK")
|
||||
client.release()
|
||||
return {
|
||||
error: "El order a actualizar no existe " + idType + ": " + idValue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user