mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-26 19:59:12 -06:00
Merge pull request #1192 from bluewave-labs/fix/be/status-service-status-string
Add better status string generation
This commit is contained in:
@@ -11,6 +11,11 @@ class StatusService {
|
||||
this.SERVICE_NAME = "StatusService";
|
||||
}
|
||||
|
||||
getStatusString = (status) => {
|
||||
if (status === true) return "up";
|
||||
if (status === false) return "down";
|
||||
return "unknown";
|
||||
};
|
||||
/**
|
||||
* Updates the status of a monitor based on the network response.
|
||||
*
|
||||
@@ -35,7 +40,7 @@ class StatusService {
|
||||
|
||||
this.logger.info({
|
||||
service: this.SERVICE_NAME,
|
||||
message: `${monitor.name} went from ${monitor.status === true ? "up" : "down"} to ${status === true ? "up" : "down"}`,
|
||||
message: `${monitor.name} went from ${this.getStatusString(monitor.status)} to ${this.getStatusString(status)}`,
|
||||
prevStatus: monitor.status,
|
||||
newStatus: status,
|
||||
});
|
||||
|
||||
@@ -27,6 +27,18 @@ describe("StatusService", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("getStatusString", () => {
|
||||
it("should return 'up' if status is true", () => {
|
||||
expect(statusService.getStatusString(true)).to.equal("up");
|
||||
});
|
||||
it("should return 'down' if status is false", () => {
|
||||
expect(statusService.getStatusString(false)).to.equal("down");
|
||||
});
|
||||
it("should return 'unknown' if status is undefined or null", () => {
|
||||
expect(statusService.getStatusString(undefined)).to.equal("unknown");
|
||||
});
|
||||
});
|
||||
|
||||
describe("updateStatus", async () => {
|
||||
beforeEach(() => {
|
||||
// statusService.insertCheck = sinon.stub().resolves;
|
||||
|
||||
Reference in New Issue
Block a user