smartlog-destination-receiver/test/test.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2022-03-07 21:45:04 +00:00
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
2018-11-11 18:40:59 +00:00
import { Qenv } from '@pushrocks/qenv';
import * as smartlog from '@pushrocks/smartlog';
const testQenv = new Qenv('./', './.nogit/');
2018-11-11 13:29:26 +00:00
import * as smartlogDestinationReceiver from '../ts/index';
2018-11-11 18:40:59 +00:00
let testSmartlogReceiver: smartlogDestinationReceiver.SmartlogDestinationReceiver;
tap.test('should create a valid SmartlogDestinationReceiver', async () => {
testSmartlogReceiver = new smartlogDestinationReceiver.SmartlogDestinationReceiver({
2020-06-07 12:33:36 +00:00
receiverEndpoint: testQenv.getEnvVarOnDemand('RECEIVER_ENDPOINT'),
passphrase: testQenv.getEnvVarOnDemand('PASSPHRASE')
2018-11-11 18:40:59 +00:00
});
});
tap.test('should send a valid message', async () => {
testSmartlogReceiver.handleLog({
timestamp: Date.now(),
context: {
company: 'Lossless GmbH',
companyunit: 'Lossless Cloud',
2020-06-05 16:25:36 +00:00
containerName: 'tapbundle-test',
2018-11-11 18:40:59 +00:00
environment: 'local',
runtime: 'node',
zone: 'gitzone'
},
type: 'log',
level: 'info',
2020-06-05 16:25:36 +00:00
correlation: {
id: '123',
type: 'none'
},
2020-06-07 12:33:36 +00:00
message: 'This is a message'
2018-11-11 18:40:59 +00:00
});
2018-11-11 13:29:26 +00:00
});
tap.start();