This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This moves to `tap` as the test framework, and increases coverage to 100% Semver: patch Ref: LOG-6338
- Loading branch information
1 parent
d8a65cd
commit a2153f1
Showing
13 changed files
with
1,246 additions
and
917 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
esm: false | ||
ts: false | ||
jsx: false | ||
check-coverage: true | ||
reporter: tap | ||
jobs: 2 | ||
nyc-arg: | ||
- --all=true | ||
- --exclude=test/ | ||
coverage-report: | ||
- text | ||
- text-summary | ||
- json | ||
- html | ||
files: | ||
- test/**/*.js | ||
branches: 98 | ||
lines: 100 | ||
functions: 100 | ||
statements: 100 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use strict' | ||
|
||
module.exports = function createOptions({ | ||
key = '< YOUR INGESTION KEY HERE >' | ||
, hostname = 'AWESOMEHOSTER' | ||
, ip = '10.0.1.101' | ||
, mac = 'C0:FF:EE:C0:FF:EE' | ||
, app = 'testing.log' | ||
, test = true | ||
, port = 1337 | ||
, failedBufRetentionLimit = null | ||
, retryTimes = null | ||
, retryTimeout = null | ||
, flushInterval = 1 // Immediate flushing should be the default | ||
, flushLimit = null | ||
, max_length = null | ||
, index_meta = null | ||
, level = null | ||
, tags = null | ||
, protocol = null | ||
, timeout = null | ||
, shimProperties | ||
} = {}) { | ||
return { | ||
key | ||
, hostname | ||
, ip | ||
, mac | ||
, app | ||
, test | ||
, logdna_url: `http://localhost:${port}` | ||
, failedBufRetentionLimit | ||
, retryTimeout | ||
, flushInterval | ||
, flushLimit | ||
, max_length | ||
, index_meta | ||
, level | ||
, retryTimes | ||
, tags | ||
, protocol | ||
, timeout | ||
, shimProperties | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
apiKey: '< YOUR INGESTION KEY HERE >' | ||
, createOptions: require('./create-options.js') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict' | ||
|
||
const {test} = require('tap') | ||
const index = require('../index.js') | ||
const logger = require('../lib/logger.js') | ||
const {apiKey, createOptions} = require('./common/index.js') | ||
|
||
test('Index exports are correct', async (t) => { | ||
t.equal(Object.keys(index).length, 5, 'property count is correct') | ||
t.match(index, { | ||
cleanUpAll: logger.cleanUpAll | ||
, createLogger: logger.createLogger | ||
, flushAll: logger.flushAll | ||
, Logger: logger.Logger | ||
, setupDefaultLogger: Function | ||
}, 'Exported properties are correct') | ||
}) | ||
|
||
test('setupDefaultLogger', async (t) => { | ||
t.test('Create the singleton', async (tt) => { | ||
const instance = index.setupDefaultLogger( | ||
apiKey | ||
, createOptions({ | ||
app: 'MyDefaultApp' | ||
}) | ||
) | ||
tt.equal(instance.constructor.name, 'Logger', 'Returned an instance') | ||
tt.equal(instance.source.app, 'MyDefaultApp', 'App name is correct') | ||
}) | ||
|
||
t.test('Singleton is returned', async (tt) => { | ||
const instance = index.setupDefaultLogger( | ||
apiKey | ||
, createOptions({ | ||
app: 'ThisWillNotWork' | ||
}) | ||
) | ||
tt.equal(instance.constructor.name, 'Logger', 'Returned an instance') | ||
tt.equal(instance.source.app, 'MyDefaultApp', 'App name is correct') | ||
}) | ||
}) |
Oops, something went wrong.