Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing test case for docker monitor type #1158

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Server/tests/db/monitorModule.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,18 @@ describe("monitorModule", () => {
url: "https://test.com",
}),
};
const mockMonitorDocker = {
_id: "monitor123",
type: "docker",
name: "Test Monitor",
url: "https://test.com",
toObject: () => ({
_id: "monitor123",
type: "http",
name: "Test Monitor",
url: "https://test.com",
}),
};

const checkDocs = [
{
Expand Down Expand Up @@ -1004,6 +1016,30 @@ describe("monitorModule", () => {
expect(result.periodUptime).to.be.a("number");
expect(result.aggregateData).to.be.an("array");
});
it("should return monitor stats with calculated values, docker type", async () => {
monitorFindByIdStub.returns(mockMonitorDocker);
req.query.sortOrder = "desc";
const result = await getMonitorStatsById(req);
expect(result).to.include.keys([
"_id",
"type",
"name",
"url",
"uptimeDuration",
"lastChecked",
"latestResponseTime",
"periodIncidents",
"periodTotalChecks",
"periodAvgResponseTime",
"periodUptime",
"aggregateData",
]);
expect(result.latestResponseTime).to.equal(100);
expect(result.periodTotalChecks).to.equal(3);
expect(result.periodIncidents).to.equal(1);
expect(result.periodUptime).to.be.a("number");
expect(result.aggregateData).to.be.an("array");
});
it("should return monitor stats with calculated values", async () => {
req.query.sortOrder = "asc";
const result = await getMonitorStatsById(req);
Expand Down