logdna/test/test.ts

37 lines
1016 B
TypeScript
Raw Normal View History

2018-11-01 17:13:34 +00:00
import { expect, tap } from '@pushrocks/tapbundle';
2018-11-02 08:07:47 +00:00
import * as logdna from '../ts/index';
2018-11-01 17:13:34 +00:00
2018-11-02 08:07:47 +00:00
import { Qenv } from '@pushrocks/qenv';
2018-11-01 17:13:34 +00:00
2018-11-02 08:07:47 +00:00
const testQenv = new Qenv('./', './.nogit');
let testLogDnaAccount: logdna.LogdnaAccount;
let testLogMessage: logdna.LogdnaMessage;
tap.test('should create a valid logDna account', async () => {
2018-11-02 12:57:14 +00:00
testLogDnaAccount = new logdna.LogdnaAccount(process.env.LOGDNA_APIKEY);
2018-11-02 08:07:47 +00:00
});
tap.test('should create a standard log message', async () => {
2018-11-02 12:57:14 +00:00
testLogMessage = logdna.LogdnaMessage.fromSmartLogPackage({
2018-11-04 17:44:28 +00:00
timestamp: Date.now(),
type: 'log',
2018-11-03 22:31:26 +00:00
level: 'info',
context: {
2018-11-02 12:57:14 +00:00
company: 'Lossless GmbH',
companyunit: 'lossless.cloud',
containerName: 'ci-mojoio-logdna',
environment: 'test',
runtime: 'node',
2018-11-04 14:37:55 +00:00
zone: 'shipzone'
2018-11-02 12:57:14 +00:00
},
2018-11-04 17:44:28 +00:00
message: 'this is an awesome log message sent by the tapbundle test'
2018-11-02 12:57:14 +00:00
});
2018-11-02 08:07:47 +00:00
});
2018-11-02 18:12:16 +00:00
tap.test('should send the message', async () => {
await testLogDnaAccount.sendLogDnaMessage(testLogMessage);
2018-11-03 15:22:32 +00:00
});
2018-11-02 18:12:16 +00:00
2018-11-02 08:07:47 +00:00
tap.start();