Add tests
This commit is contained in:
1 parent
cfe7d2a359
commit
6d4e944a58
10 files changed
+601
-11
No files matched your search
@@ -247,6 +247,20 @@ describe("monitorValidation — strategy gating", () => {
|
||||
expect(parsed.monitors[0].dockerLogsEnabled).toBe(false);
|
||||
});
|
||||
|
||||
it("defaults the docker alert switches to false on imported docker monitors", () => {
|
||||
const parsed = importMonitorsBodyValidation.parse({
|
||||
monitors: [
|
||||
{
|
||||
name: "Imported Docker",
|
||||
type: "docker",
|
||||
url: "unix:///var/run/docker.sock",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(parsed.monitors[0].dockerAlertOnStopped).toBe(false);
|
||||
expect(parsed.monitors[0].dockerAlertOnUnhealthy).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects strategy on imported non-pagespeed monitors", () => {
|
||||
expect(() =>
|
||||
importMonitorsBodyValidation.parse({
|
||||
@@ -818,3 +832,43 @@ describe("monitorValidation — Docker TLS credentials", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("monitorValidation — docker alert switches", () => {
|
||||
describe("createMonitorBodyValidation", () => {
|
||||
it("retains dockerAlertOnStopped and dockerAlertOnUnhealthy on a docker monitor", () => {
|
||||
const parsed = createMonitorBodyValidation.parse({
|
||||
name: "Docker host",
|
||||
type: "docker",
|
||||
url: "unix:///var/run/docker.sock",
|
||||
dockerAlertOnStopped: true,
|
||||
dockerAlertOnUnhealthy: true,
|
||||
});
|
||||
|
||||
expect(parsed.dockerAlertOnStopped).toBe(true);
|
||||
expect(parsed.dockerAlertOnUnhealthy).toBe(true);
|
||||
});
|
||||
|
||||
it("leaves the switches undefined when omitted", () => {
|
||||
const parsed = createMonitorBodyValidation.parse({
|
||||
name: "Docker host",
|
||||
type: "docker",
|
||||
url: "unix:///var/run/docker.sock",
|
||||
});
|
||||
|
||||
expect(parsed.dockerAlertOnStopped).toBeUndefined();
|
||||
expect(parsed.dockerAlertOnUnhealthy).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("editMonitorBodyValidation", () => {
|
||||
it("retains dockerAlertOnStopped and dockerAlertOnUnhealthy on edits", () => {
|
||||
const parsed = editMonitorBodyValidation.parse({
|
||||
dockerAlertOnStopped: true,
|
||||
dockerAlertOnUnhealthy: false,
|
||||
});
|
||||
|
||||
expect(parsed.dockerAlertOnStopped).toBe(true);
|
||||
expect(parsed.dockerAlertOnUnhealthy).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user