mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-22 01:22:54 +00:00
Resolve "Transition to ESLint"
This commit is contained in:
committed by
Rainer Killinger
parent
ca1d2444e0
commit
418ba67d15
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/*
|
||||
* Copyright (C) 2020 StApps
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@@ -18,7 +19,8 @@ import {
|
||||
SCMonitoringConfiguration,
|
||||
SCMonitoringLogAction,
|
||||
SCMonitoringMailAction,
|
||||
SCMonitoringWatcher, SCThings
|
||||
SCMonitoringWatcher,
|
||||
SCThings,
|
||||
} from '@openstapps/core';
|
||||
import {Logger} from '@openstapps/logger';
|
||||
import {SearchResponse} from 'elasticsearch';
|
||||
@@ -26,7 +28,7 @@ import {MailQueue} from '../../../src/notification/mail-queue';
|
||||
import {setUp} from '../../../src/storage/elasticsearch/monitoring';
|
||||
|
||||
import {getTransport} from '../../common';
|
||||
import { expect } from 'chai';
|
||||
import {expect} from 'chai';
|
||||
import sinon from 'sinon';
|
||||
import cron from 'node-cron';
|
||||
|
||||
@@ -35,16 +37,15 @@ describe('Monitoring', async function () {
|
||||
const logAction: SCMonitoringLogAction = {
|
||||
message: 'Foo monitoring message',
|
||||
prefix: 'Backend Monitoring',
|
||||
type: 'log'
|
||||
type: 'log',
|
||||
};
|
||||
const mailAction: SCMonitoringMailAction = {
|
||||
message: 'Bar monitoring message',
|
||||
recipients: ['xyz@xyz.com'],
|
||||
subject: 'Backend Monitoring',
|
||||
type: 'mail'
|
||||
type: 'mail',
|
||||
};
|
||||
let transport: any;
|
||||
// @ts-ignore
|
||||
let mailQueue: any;
|
||||
beforeEach(async function () {
|
||||
transport = getTransport(true);
|
||||
@@ -55,52 +56,52 @@ describe('Monitoring', async function () {
|
||||
sandbox.restore();
|
||||
});
|
||||
// const sandbox = sinon.createSandbox();
|
||||
let cronScheduleStub: sinon.SinonStub
|
||||
let cronScheduleStub: sinon.SinonStub;
|
||||
const minLengthWatcher: SCMonitoringWatcher = {
|
||||
actions: [logAction, mailAction],
|
||||
conditions: [
|
||||
{
|
||||
length: 10,
|
||||
type: 'MinimumLength'
|
||||
}
|
||||
type: 'MinimumLength',
|
||||
},
|
||||
],
|
||||
name: 'foo watcher',
|
||||
query: {foo: 'bar'},
|
||||
triggers: [
|
||||
{
|
||||
executionTime: 'monthly',
|
||||
name: 'beginning of month'
|
||||
name: 'beginning of month',
|
||||
},
|
||||
{
|
||||
executionTime: 'daily',
|
||||
name: 'every night'
|
||||
}
|
||||
]
|
||||
name: 'every night',
|
||||
},
|
||||
],
|
||||
};
|
||||
const maxLengthWatcher: SCMonitoringWatcher = {
|
||||
actions: [logAction, mailAction],
|
||||
conditions: [
|
||||
{
|
||||
length: 30,
|
||||
type: 'MaximumLength'
|
||||
}
|
||||
type: 'MaximumLength',
|
||||
},
|
||||
],
|
||||
name: 'foo watcher',
|
||||
query: {bar: 'foo'},
|
||||
triggers: [
|
||||
{
|
||||
executionTime: 'hourly',
|
||||
name: 'every hour'
|
||||
name: 'every hour',
|
||||
},
|
||||
{
|
||||
executionTime: 'weekly',
|
||||
name: 'every week'
|
||||
name: 'every week',
|
||||
},
|
||||
]
|
||||
],
|
||||
};
|
||||
const monitoringConfig: SCMonitoringConfiguration = {
|
||||
actions: [logAction, mailAction],
|
||||
watchers: [minLengthWatcher, maxLengthWatcher]
|
||||
watchers: [minLengthWatcher, maxLengthWatcher],
|
||||
};
|
||||
|
||||
it('should create a schedule for each trigger', async function () {
|
||||
@@ -111,19 +112,18 @@ describe('Monitoring', async function () {
|
||||
|
||||
it('should log errors where conditions failed', async function () {
|
||||
const fakeSearchResponse: Partial<ApiResponse<SearchResponse<SCThings>>> = {
|
||||
// @ts-ignore
|
||||
body: {
|
||||
took: 12,
|
||||
timed_out: false,
|
||||
// @ts-ignore
|
||||
_shards: {},
|
||||
// @ts-ignore
|
||||
hits: {
|
||||
total: 123
|
||||
},
|
||||
took: 12,
|
||||
timed_out: false,
|
||||
// @ts-expect-error not assignable
|
||||
_shards: {},
|
||||
// @ts-expect-error not assignable
|
||||
hits: {
|
||||
total: 123,
|
||||
},
|
||||
},
|
||||
};
|
||||
let fakeClient = new Client({node: 'http://foohost:9200'});
|
||||
const fakeClient = new Client({node: 'http://foohost:9200'});
|
||||
const loggerErrorStub = sandbox.stub(Logger, 'error');
|
||||
const mailQueueSpy = sinon.spy(mailQueue, 'push');
|
||||
cronScheduleStub.yields();
|
||||
|
||||
Reference in New Issue
Block a user