build dist
This commit is contained in:
58
dist/datasource-zabbix/specs/datasource.spec.js
vendored
58
dist/datasource-zabbix/specs/datasource.spec.js
vendored
@@ -1,16 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
System.register(["lodash", "q", "../module", "../datasource"], function (_export, _context) {
|
||||
System.register(["lodash", "../module", "../datasource"], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, Q, Promise, Datasource, zabbixTemplateFormat;
|
||||
var _, Datasource, zabbixTemplateFormat;
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_q) {
|
||||
Q = _q.default;
|
||||
Promise = _q.Promise;
|
||||
}, function (_module) {
|
||||
Datasource = _module.Datasource;
|
||||
}, function (_datasource) {
|
||||
@@ -24,27 +21,26 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
beforeEach(function () {
|
||||
ctx.instanceSettings = {
|
||||
jsonData: {
|
||||
alerting: true,
|
||||
alerting: false,
|
||||
username: 'zabbix',
|
||||
password: 'zabbix',
|
||||
trends: true,
|
||||
trendsFrom: '14d',
|
||||
trendsRange: '7d',
|
||||
dbConnection: {
|
||||
enabled: false
|
||||
}
|
||||
dbConnectionEnable: false
|
||||
}
|
||||
};
|
||||
ctx.templateSrv = {};
|
||||
ctx.alertSrv = {};
|
||||
ctx.dashboardSrv = {};
|
||||
ctx.backendSrv = {
|
||||
datasourceRequest: jest.fn()
|
||||
};
|
||||
ctx.datasourceSrv = {};
|
||||
ctx.zabbixAlertingSrv = {
|
||||
setPanelAlertState: jest.fn(),
|
||||
removeZabbixThreshold: jest.fn()
|
||||
};
|
||||
ctx.zabbix = function () {};
|
||||
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.backendSrv, ctx.datasourceSrv, ctx.zabbixAlertingSrv);
|
||||
});
|
||||
|
||||
describe('When querying data', function () {
|
||||
@@ -52,9 +48,6 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
ctx.ds.replaceTemplateVars = function (str) {
|
||||
return str;
|
||||
};
|
||||
ctx.ds.alertQuery = function () {
|
||||
return Q.when([]);
|
||||
};
|
||||
});
|
||||
|
||||
ctx.options = {
|
||||
@@ -117,10 +110,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
ctx.ds.replaceTemplateVars = function (str) {
|
||||
return str;
|
||||
};
|
||||
ctx.ds.alertQuery = function () {
|
||||
return Q.when([]);
|
||||
};
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([{ clock: "1500010200", itemid: "10100", ns: "900111000", value: "Linux first" }, { clock: "1500010300", itemid: "10100", ns: "900111000", value: "Linux 2nd" }, { clock: "1500010400", itemid: "10100", ns: "900111000", value: "Linux last" }]));
|
||||
ctx.ds.zabbix.zabbixAPI.getHistory = jest.fn().mockReturnValue(Promise.resolve([{ clock: "1500010200", itemid: "10100", ns: "900111000", value: "Linux first" }, { clock: "1500010300", itemid: "10100", ns: "900111000", value: "Linux 2nd" }, { clock: "1500010400", itemid: "10100", ns: "900111000", value: "Linux last" }]));
|
||||
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([{
|
||||
hosts: [{ hostid: "10001", name: "Zabbix server" }],
|
||||
@@ -244,10 +234,10 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
return str;
|
||||
};
|
||||
ctx.ds.zabbix = {
|
||||
getGroups: jest.fn().mockReturnValue(Q.when([])),
|
||||
getHosts: jest.fn().mockReturnValue(Q.when([])),
|
||||
getApps: jest.fn().mockReturnValue(Q.when([])),
|
||||
getItems: jest.fn().mockReturnValue(Q.when([]))
|
||||
getGroups: jest.fn().mockReturnValue(Promise.resolve([])),
|
||||
getHosts: jest.fn().mockReturnValue(Promise.resolve([])),
|
||||
getApps: jest.fn().mockReturnValue(Promise.resolve([])),
|
||||
getItems: jest.fn().mockReturnValue(Promise.resolve([]))
|
||||
};
|
||||
});
|
||||
|
||||
@@ -411,9 +401,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
"hosts": [{ "hostid": "10631", "name": "Test host" }],
|
||||
"item": "Test item"
|
||||
}];
|
||||
ctx.ds.zabbix.getItemsFromTarget = function () {
|
||||
return Promise.resolve(targetItems);
|
||||
};
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve(targetItems));
|
||||
|
||||
options = {
|
||||
"panelId": 10,
|
||||
@@ -434,9 +422,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
"expression": "{15915}<100"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = function () {
|
||||
return Promise.resolve(itemTriggers);
|
||||
};
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds).toHaveLength(1);
|
||||
@@ -453,9 +439,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
"expression": "{15915}<=100"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = function () {
|
||||
return Promise.resolve(itemTriggers);
|
||||
};
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
@@ -472,9 +456,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
"expression": "{15915}>=30"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = function () {
|
||||
return Promise.resolve(itemTriggers);
|
||||
};
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
@@ -491,9 +473,7 @@ System.register(["lodash", "q", "../module", "../datasource"], function (_export
|
||||
"expression": "{15915}=50"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = function () {
|
||||
return Promise.resolve(itemTriggers);
|
||||
};
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
|
||||
File diff suppressed because one or more lines are too long
56
dist/datasource-zabbix/specs/migrations.test.js
vendored
Normal file
56
dist/datasource-zabbix/specs/migrations.test.js
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['../migrations'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var migrateDSConfig, DS_CONFIG_SCHEMA;
|
||||
return {
|
||||
setters: [function (_migrations) {
|
||||
migrateDSConfig = _migrations.migrateDSConfig;
|
||||
DS_CONFIG_SCHEMA = _migrations.DS_CONFIG_SCHEMA;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('Migrations', function () {
|
||||
var ctx = {};
|
||||
|
||||
describe('When migrating datasource config', function () {
|
||||
beforeEach(function () {
|
||||
ctx.jsonData = {
|
||||
dbConnection: {
|
||||
enable: true,
|
||||
datasourceId: 1
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should change direct DB connection setting to flat style', function () {
|
||||
migrateDSConfig(ctx.jsonData);
|
||||
expect(ctx.jsonData).toMatchObject({
|
||||
dbConnectionEnable: true,
|
||||
dbConnectionDatasourceId: 1,
|
||||
schema: DS_CONFIG_SCHEMA
|
||||
});
|
||||
});
|
||||
|
||||
it('should not touch anything if schema is up to date', function () {
|
||||
ctx.jsonData = {
|
||||
futureOptionOne: 'foo',
|
||||
futureOptionTwo: 'bar',
|
||||
schema: DS_CONFIG_SCHEMA
|
||||
};
|
||||
migrateDSConfig(ctx.jsonData);
|
||||
expect(ctx.jsonData).toMatchObject({
|
||||
futureOptionOne: 'foo',
|
||||
futureOptionTwo: 'bar',
|
||||
schema: DS_CONFIG_SCHEMA
|
||||
});
|
||||
expect(ctx.jsonData.dbConnectionEnable).toBeUndefined();
|
||||
expect(ctx.jsonData.dbConnectionDatasourceId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=migrations.test.js.map
|
||||
1
dist/datasource-zabbix/specs/migrations.test.js.map
vendored
Normal file
1
dist/datasource-zabbix/specs/migrations.test.js.map
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["../../../src/datasource-zabbix/specs/migrations.test.js"],"names":["migrateDSConfig","DS_CONFIG_SCHEMA","describe","ctx","beforeEach","jsonData","dbConnection","enable","datasourceId","it","expect","toMatchObject","dbConnectionEnable","dbConnectionDatasourceId","schema","futureOptionOne","futureOptionTwo","toBeUndefined"],"mappings":";;;;;;;;AAASA,qB,eAAAA,e;AAAiBC,sB,eAAAA,gB;;;;AAE1BC,eAAS,YAAT,EAAuB,YAAM;AAC3B,YAAIC,MAAM,EAAV;;AAEAD,iBAAS,kCAAT,EAA6C,YAAM;AACjDE,qBAAW,YAAM;AACfD,gBAAIE,QAAJ,GAAe;AACbC,4BAAc;AACZC,wBAAQ,IADI;AAEZC,8BAAc;AAFF;AADD,aAAf;AAMD,WAPD;;AASAC,aAAG,0DAAH,EAA+D,YAAM;AACnET,4BAAgBG,IAAIE,QAApB;AACAK,mBAAOP,IAAIE,QAAX,EAAqBM,aAArB,CAAmC;AACjCC,kCAAoB,IADa;AAEjCC,wCAA0B,CAFO;AAGjCC,sBAAQb;AAHyB,aAAnC;AAKD,WAPD;;AASAQ,aAAG,mDAAH,EAAwD,YAAM;AAC5DN,gBAAIE,QAAJ,GAAe;AACbU,+BAAiB,KADJ;AAEbC,+BAAiB,KAFJ;AAGbF,sBAAQb;AAHK,aAAf;AAKAD,4BAAgBG,IAAIE,QAApB;AACAK,mBAAOP,IAAIE,QAAX,EAAqBM,aAArB,CAAmC;AACjCI,+BAAiB,KADgB;AAEjCC,+BAAiB,KAFgB;AAGjCF,sBAAQb;AAHyB,aAAnC;AAKAS,mBAAOP,IAAIE,QAAJ,CAAaO,kBAApB,EAAwCK,aAAxC;AACAP,mBAAOP,IAAIE,QAAJ,CAAaQ,wBAApB,EAA8CI,aAA9C;AACD,WAdD;AAeD,SAlCD;AAmCD,OAtCD","file":"migrations.test.js","sourcesContent":["import { migrateDSConfig, DS_CONFIG_SCHEMA } from '../migrations';\n\ndescribe('Migrations', () => {\n let ctx = {};\n\n describe('When migrating datasource config', () => {\n beforeEach(() => {\n ctx.jsonData = {\n dbConnection: {\n enable: true,\n datasourceId: 1\n }\n };\n });\n\n it('should change direct DB connection setting to flat style', () => {\n migrateDSConfig(ctx.jsonData);\n expect(ctx.jsonData).toMatchObject({\n dbConnectionEnable: true,\n dbConnectionDatasourceId: 1,\n schema: DS_CONFIG_SCHEMA\n });\n });\n\n it('should not touch anything if schema is up to date', () => {\n ctx.jsonData = {\n futureOptionOne: 'foo',\n futureOptionTwo: 'bar',\n schema: DS_CONFIG_SCHEMA\n };\n migrateDSConfig(ctx.jsonData);\n expect(ctx.jsonData).toMatchObject({\n futureOptionOne: 'foo',\n futureOptionTwo: 'bar',\n schema: DS_CONFIG_SCHEMA\n });\n expect(ctx.jsonData.dbConnectionEnable).toBeUndefined();\n expect(ctx.jsonData.dbConnectionDatasourceId).toBeUndefined();\n });\n });\n});\n"]}
|
||||
Reference in New Issue
Block a user