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