Skip to content

Commit

Permalink
fix: push disabled lightweight monitor correctly (#899)
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed Feb 23, 2024
1 parent 27182c6 commit f3d578a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
13 changes: 8 additions & 5 deletions __tests__/push/monitor.test.ts
Expand Up @@ -205,8 +205,10 @@ heartbeat.monitors:
id: "foo"
name: "foo"
`);
opts.pattern = '.yaml$';
const monitors = await createLightweightMonitors(PROJECT_DIR, opts);
const monitors = await createLightweightMonitors(PROJECT_DIR, {
...opts,
pattern: '.yaml$',
});
expect(monitors.length).toBe(0);
});

Expand All @@ -221,16 +223,17 @@ heartbeat.monitors:
expect(monitors.length).toBe(0);
});

it('skip disabled monitors', async () => {
it('push disabled monitors', async () => {
await writeHBFile(`
heartbeat.monitors:
- type: http
name: "disabled"
schedule: "@every 1m"
id: "http"
id: "disabled"
enabled: false
`);
const monitors = await createLightweightMonitors(PROJECT_DIR, opts);
expect(monitors.length).toBe(0);
expect(monitors.length).toBe(1);
});

it('prefer local monitor config', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/push/monitor.ts
Expand Up @@ -204,11 +204,8 @@ export async function createLightweightMonitors(
}

for (const monNode of monitorSeq.items) {
// Skip browser monitors and disabled monitors from pushing
if (
monNode.get('type') === 'browser' ||
monNode.get('enabled') === false
) {
// Skip browser monitors from the YML files
if (monNode.get('type') === 'browser') {
continue;
}
const config = monNode.toJSON();
Expand Down

0 comments on commit f3d578a

Please sign in to comment.