smartlog-destination-receiver/test/test.ts
2024-05-18 01:34:54 +02:00

39 lines
1.1 KiB
TypeScript

import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import { Qenv } from '@push.rocks/qenv';
import * as smartlog from '@push.rocks/smartlog';
const testQenv = new Qenv('./', './.nogit/');
import * as smartlogDestinationReceiver from '../ts/index.js';
let testSmartlogReceiver: smartlogDestinationReceiver.SmartlogDestinationReceiver;
tap.test('should create a valid SmartlogDestinationReceiver', async () => {
testSmartlogReceiver = new smartlogDestinationReceiver.SmartlogDestinationReceiver({
receiverEndpoint: await testQenv.getEnvVarOnDemand('RECEIVER_ENDPOINT'),
passphrase: await testQenv.getEnvVarOnDemand('PASSPHRASE'),
});
});
tap.test('should send a valid message', async () => {
testSmartlogReceiver.handleLog({
timestamp: Date.now(),
context: {
company: 'Lossless GmbH',
companyunit: 'Lossless Cloud',
containerName: 'tapbundle-test',
environment: 'local',
runtime: 'node',
zone: 'gitzone',
},
type: 'log',
level: 'info',
correlation: {
id: '123',
type: 'none',
},
message: 'This is a message',
});
});
export default tap.start();