-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
26 lines (21 loc) · 788 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import test from 'ava';
const AWS = require('aws-sdk-mock');
test('send line to Firehose', async (t) => {
process.env.FH_DELIVERY_STREAM = 'test';
const req = { rawBody: 'incubator_sensor1.lab2_unique.1h temp=30i 1554153451000000000' };
const res = {
status: (n) => {
// Check if 201 response code is set
t.is(n, 201);
return { send: () => t.pass() };
},
};
const expectedData = new Buffer.from(
'{"timestamp":1554153451000000000,"measurement":"incubator_sensor1.lab2_unique.1h","fields":[{"temp":30}],"tags":[]}\n',
);
AWS.mock('Firehose', 'putRecord', async (params) => {
// Check if the data in params is consistent
t.deepEqual(params.Record.Data, expectedData);
});
return require('.').processData(req, res, () => {});
});