Skip to content

Commit 0f7c341

Browse files
committed
finished kubernetes function
1 parent 6637717 commit 0f7c341

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

__backend-tests__/chronosMethods.test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const postgres = require('../chronos_npm_package/controllers/postgres.js');
99
jest.mock('../chronos_npm_package/controllers/utilities.js', () => ({
1010
validateInput: jest.fn(config => config),
1111
addNotifications: jest.fn(config => config),
12+
testMetricsQuery: jest.fn(config => config),
13+
getMetricsURI: jest.fn(config => config),
1214
}));
1315

1416
// mock propogate from Chronos
@@ -21,6 +23,7 @@ jest.mock('../chronos_npm_package/controllers/mongo.js', () => ({
2123
docker: jest.fn(config => config),
2224
health: jest.fn(config => config),
2325
communications: jest.fn(config => config),
26+
serverQuery: jest.fn(config => config),
2427
}));
2528

2629
jest.mock('../chronos_npm_package/controllers/postgres.js', () => ({
@@ -29,6 +32,7 @@ jest.mock('../chronos_npm_package/controllers/postgres.js', () => ({
2932
docker: jest.fn(config => config),
3033
health: jest.fn(config => config),
3134
communications: jest.fn(config => config),
35+
serverQuery: jest.fn(config => config),
3236
}));
3337

3438
describe('Chronos Config', () => {
@@ -139,4 +143,63 @@ describe('Chronos Config', () => {
139143
}
140144
});
141145
});
146+
describe('kafka', () => {
147+
test('should check if kafka is functional', async () => {
148+
const config = {
149+
microservice: 'test',
150+
interval: 300,
151+
mode: 'micro',
152+
dockerized: true,
153+
database: {
154+
connection: 'REST',
155+
type: 'MongoDB',
156+
URI: process.env.CHRONOS_URI,
157+
},
158+
notifications: [],
159+
};
160+
const { database, dockerized } = config;
161+
const falseDock = { dockerized: false };
162+
const chronos = new Chronos(config);
163+
chronos.kafka();
164+
await helpers.testMetricsQuery(config);
165+
if (database.type === 'MongoDB') {
166+
expect(mongo.connect).toHaveBeenCalledWith(config);
167+
expect(mongo.serverQuery).toHaveBeenCalledWith(config);
168+
}
169+
if (database.type === 'PostgreSQL') {
170+
expect(postgres.connect).toHaveBeenCalledWith(config);
171+
expect(postgres.serverQuery).toHaveBeenCalledWith(config);
172+
}
173+
});
174+
});
175+
176+
describe('kubernetes', () => {
177+
test('should check if kubernetes is functional', async () => {
178+
const config = {
179+
microservice: 'test',
180+
interval: 300,
181+
mode: 'micro',
182+
dockerized: true,
183+
database: {
184+
connection: 'REST',
185+
type: 'MongoDB',
186+
URI: process.env.CHRONOS_URI,
187+
},
188+
notifications: [],
189+
};
190+
const { database, dockerized } = config;
191+
const falseDock = { dockerized: false };
192+
const chronos = new Chronos(config);
193+
chronos.kubernetes();
194+
await helpers.testMetricsQuery(config);
195+
if (database.type === 'MongoDB') {
196+
expect(mongo.connect).toHaveBeenCalledWith(config);
197+
expect(mongo.serverQuery).toHaveBeenCalledWith(config);
198+
}
199+
if (database.type === 'PostgreSQL') {
200+
expect(postgres.connect).toHaveBeenCalledWith(config);
201+
expect(postgres.serverQuery).toHaveBeenCalledWith(config);
202+
}
203+
});
204+
});
142205
});

0 commit comments

Comments
 (0)