2018-10-31 16:42:18 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
2018-11-11 00:38:19 +00:00
|
|
|
import * as smartlog from '@pushrocks/smartlog';
|
|
|
|
import * as smarthash from '@pushrocks/smarthash';
|
|
|
|
|
2018-10-31 16:42:18 +00:00
|
|
|
import * as smartlogReceiver from '../ts/index';
|
|
|
|
|
|
|
|
let testReceiver: smartlogReceiver.SmartlogReceiver;
|
2018-11-11 00:38:19 +00:00
|
|
|
let testSmartlog = smartlog.defaultLogger;
|
|
|
|
testSmartlog.enableConsole();
|
2018-10-31 16:42:18 +00:00
|
|
|
|
2018-11-11 00:38:19 +00:00
|
|
|
tap.test('should create a valid SmartlogReceiver', async () => {
|
|
|
|
testReceiver = new smartlogReceiver.SmartlogReceiver({
|
|
|
|
passphrase: 'hi',
|
|
|
|
smartlogInstance: testSmartlog,
|
|
|
|
validatorFunction: () => {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
expect(testReceiver).to.be.instanceof(smartlogReceiver.SmartlogReceiver);
|
2018-10-31 16:45:51 +00:00
|
|
|
});
|
2018-10-31 16:42:18 +00:00
|
|
|
|
2018-11-11 00:38:19 +00:00
|
|
|
tap.test('should receive a message', async () => {
|
|
|
|
testReceiver.handleAuthenticatedLog({
|
|
|
|
auth: smarthash.sha256FromStringSync('hi'),
|
|
|
|
logPackage: {
|
|
|
|
logContext: {
|
|
|
|
company: 'Lossless GmbH',
|
|
|
|
companyunit: 'Lossless Cloud',
|
|
|
|
containerName: null,
|
|
|
|
environment: 'staging',
|
|
|
|
runtime: 'node',
|
|
|
|
zone: 'gitzone'
|
|
|
|
},
|
|
|
|
logLevel: 'info',
|
|
|
|
message: 'hi there'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2018-10-31 16:42:18 +00:00
|
|
|
tap.start();
|