mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
more tests
This commit is contained in:
parent
35ad3aa072
commit
bec646d797
@ -24,6 +24,19 @@ test('adds old fields to feature', t => {
|
||||
t.deepEqual(mappedFeature.parameters, feature.strategies[0].parameters);
|
||||
});
|
||||
|
||||
test('adds old fields to feature handles missing strategies field', t => {
|
||||
const feature = {
|
||||
name: 'test',
|
||||
enabled: 0
|
||||
};
|
||||
|
||||
const mappedFeature = mapper.addOldFields(feature);
|
||||
|
||||
t.true(mappedFeature.name === feature.name);
|
||||
t.true(mappedFeature.enabled === feature.enabled);
|
||||
t.true(mappedFeature.strategies.length === 0);
|
||||
});
|
||||
|
||||
test('transforms fields to new format', t => {
|
||||
const feature = {
|
||||
name: 'test',
|
||||
|
@ -40,7 +40,7 @@ module.exports = function (app, config) {
|
||||
instanceId: cleaned.instanceId,
|
||||
clientIp,
|
||||
}))
|
||||
.catch(err => catchLogAndSendErrorResponse(err, res));
|
||||
.catch(err => logger.error('failed to store metrics', err));
|
||||
|
||||
res.status(202).end();
|
||||
});
|
||||
@ -64,7 +64,7 @@ module.exports = function (app, config) {
|
||||
}))
|
||||
.then(() => logger.info(`New client registered with
|
||||
appName=${cleaned.appName} and instanceId=${cleaned.instanceId}`))
|
||||
.catch(err => catchLogAndSendErrorResponse(err, res));
|
||||
.catch(err => logger.error('failed to register client', err));
|
||||
|
||||
res.status(202).end();
|
||||
});
|
||||
|
@ -22,6 +22,27 @@ test.serial('should register client', async (t) => {
|
||||
.then(destroy);
|
||||
});
|
||||
|
||||
test.serial('should allow client to register multiple times', async (t) => {
|
||||
const { request, destroy } = await setupApp('metrics_serial');
|
||||
const clientRegistration = {
|
||||
appName: 'multipleRegistration',
|
||||
instanceId: 'test',
|
||||
strategies: ['default', 'another'],
|
||||
started: Date.now(),
|
||||
interval: 10
|
||||
};
|
||||
|
||||
return request
|
||||
.post('/api/client/register')
|
||||
.send(clientRegistration)
|
||||
.expect(202)
|
||||
.then(() => request
|
||||
.post('/api/client/register')
|
||||
.send(clientRegistration)
|
||||
.expect(202))
|
||||
.then(destroy);
|
||||
});
|
||||
|
||||
test.serial('should accept client metrics', async t => {
|
||||
const { request, destroy } = await setupApp('metrics_serial');
|
||||
return request
|
||||
@ -75,4 +96,3 @@ test.serial('should get list of applications', async t => {
|
||||
})
|
||||
.then(destroy);
|
||||
});
|
||||
|
||||
|
@ -62,6 +62,14 @@ test('should require strategies field', () => {
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
test('should validate client metrics', () => {
|
||||
const { request } = getSetup();
|
||||
return request
|
||||
.post('/api/client/metrics')
|
||||
.send({random: 'blush'})
|
||||
.expect(400);
|
||||
});
|
||||
|
||||
|
||||
test('should accept client metrics', () => {
|
||||
const { request } = getSetup();
|
||||
|
Loading…
Reference in New Issue
Block a user