smartlog-destination-receiver/test/test.ts

39 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-05-17 23:32:05 +00:00
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import { Qenv } from '@push.rocks/qenv';
import * as smartlog from '@push.rocks/smartlog';
2018-11-11 18:40:59 +00:00
const testQenv = new Qenv('./', './.nogit/');
2022-06-26 07:27:01 +00:00
import * as smartlogDestinationReceiver from '../ts/index.js';
2018-11-11 13:29:26 +00:00
2018-11-11 18:40:59 +00:00
let testSmartlogReceiver: smartlogDestinationReceiver.SmartlogDestinationReceiver;
tap.test('should create a valid SmartlogDestinationReceiver', async () => {
testSmartlogReceiver = new smartlogDestinationReceiver.SmartlogDestinationReceiver({
2024-05-17 23:34:54 +00:00
receiverEndpoint: await testQenv.getEnvVarOnDemand('RECEIVER_ENDPOINT'),
passphrase: await 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',
2022-06-26 07:27:01 +00:00
zone: 'gitzone',
2018-11-11 18:40:59 +00:00
},
type: 'log',
level: 'info',
2020-06-05 16:25:36 +00:00
correlation: {
id: '123',
2022-06-26 07:27:01 +00:00
type: 'none',
2020-06-05 16:25:36 +00:00
},
2022-06-26 07:27:01 +00:00
message: 'This is a message',
2018-11-11 18:40:59 +00:00
});
2018-11-11 13:29:26 +00:00
});
2024-05-17 23:32:05 +00:00
export default tap.start();