1 | const request = require('supertest-as-promised');
|
2 | const chai = require('chai');
|
3 | const expect = chai.expect;
|
4 | const asPromised = require('chai-as-promised');
|
5 | chai.use(asPromised);
|
6 | const HTTPStatus = require('http-status');
|
7 | const TestConfig = require('./config');
|
8 | const log = require('../config').log;
|
9 |
|
10 | describe('chillastic full routes', () => {
|
11 | log.level('debug');
|
12 |
|
13 | it('returns 400 response code when mutator src not found', (done) => {
|
14 | const task = {
|
15 | source: TestConfig.elasticsearch.source,
|
16 | destination: TestConfig.elasticsearch.destination,
|
17 | transfer: {
|
18 | documents: {
|
19 | fromIndices: '*'
|
20 | }
|
21 | },
|
22 | mutators: {
|
23 | actions: [{id: 'doesNotExist'}]
|
24 | }
|
25 | };
|
26 |
|
27 | const app = require('../index')(TestConfig.redis.host, TestConfig.redis.port, 7001);
|
28 | const agent = request(app);
|
29 | agent.post('/tasks/doesNotExist')
|
30 | .send(task)
|
31 | .expect(HTTPStatus.BAD_REQUEST)
|
32 | .then((res) => {
|
33 | expect(res.body.error).to.equal('Src for mutator id doesNotExist not found');
|
34 | app.services.manager.setRunning(false);
|
35 | app.services.worker.killStopped();
|
36 | done();
|
37 | })
|
38 | .catch((err) => done(err));
|
39 | });
|
40 |
|
41 | it('returns 400 response code when filter src not found', (done) => {
|
42 | const task = {
|
43 | source: TestConfig.elasticsearch.source,
|
44 | destination: TestConfig.elasticsearch.destination,
|
45 | transfer: {
|
46 | documents: {
|
47 | fromIndices: '*',
|
48 | filters: {
|
49 | actions: [{id: 'doesNotExist'}]
|
50 | }
|
51 | }
|
52 | }
|
53 | };
|
54 |
|
55 | const app = require('../index')(TestConfig.redis.host, TestConfig.redis.port, 7001);
|
56 | const agent = request(app);
|
57 | agent.post('/tasks/doesNotExist')
|
58 | .send(task)
|
59 | .expect(HTTPStatus.BAD_REQUEST)
|
60 | .then((res) => {
|
61 | expect(res.body.error).to.equal('Src for filter id doesNotExist not found');
|
62 | app.services.manager.setRunning(false);
|
63 | app.services.worker.killStopped();
|
64 | done();
|
65 | })
|
66 | .catch((err) => done(err));
|
67 | });
|
68 |
|
69 | }); |
\ | No newline at end of file |