Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: modernize the sample tests (#356)
- Loading branch information
1 parent
a55c43e
commit 69dbf0e
Showing
11 changed files
with
162 additions
and
228 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
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 |
---|---|---|
@@ -1,35 +1,32 @@ | ||
{ | ||
"name": "nodejs-docs-samples-logging", | ||
"version": "0.0.1", | ||
"private": true, | ||
"license": "Apache-2.0", | ||
"author": "Google Inc.", | ||
"repository": "googleapis/nodejs-logging", | ||
"files": [ | ||
"*.js" | ||
], | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "nyc mocha system-test/ test/" | ||
"test": "mocha system-test --timeout 60000" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/logging": "^4.1.1", | ||
"@google-cloud/logging-bunyan": "^0.9.0", | ||
"@google-cloud/logging-winston": "^0.10.0", | ||
"@google-cloud/storage": "^2.0.2", | ||
"bunyan": "^1.8.12", | ||
"express": "^4.16.3", | ||
"fluent-logger": "^3.0.0", | ||
"winston": "^2.4.0", | ||
"yargs": "^12.0.0" | ||
}, | ||
"devDependencies": { | ||
"@google-cloud/nodejs-repo-tools": "^3.0.0", | ||
"assert-rejects": "^1.0.0", | ||
"chai": "^4.2.0", | ||
"execa": "^1.0.0", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.0.0", | ||
"proxyquire": "^2.0.1", | ||
"sinon": "^7.0.0", | ||
"supertest": "^3.1.0", | ||
"proxyquire": "^2.1.0", | ||
"supertest": "^3.3.0", | ||
"uuid": "^3.3.0" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
--- | ||
env: | ||
mocha: true | ||
rules: | ||
node/no-unpublished-require: off | ||
node/no-unsupported-features: off | ||
no-empty: off |
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,55 @@ | ||
/** | ||
* Copyright 2017, Google, Inc. | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const proxyquire = require('proxyquire'); | ||
const request = require('supertest'); | ||
const {assert} = require('chai'); | ||
|
||
describe('fluent', () => { | ||
it('should log error', done => { | ||
let loggerCalled = false; | ||
|
||
const structuredLogger = { | ||
emit: name => { | ||
loggerCalled = true; | ||
assert.strictEqual(name, 'errors'); | ||
}, | ||
}; | ||
|
||
const app = proxyquire('../fluent', { | ||
'fluent-logger': { | ||
createFluentSender: (name, options) => { | ||
assert.strictEqual(name, 'myapp'); | ||
assert.deepStrictEqual(options, { | ||
host: 'localhost', | ||
port: 24224, | ||
timeout: 3.0, | ||
}); | ||
return structuredLogger; | ||
}, | ||
}, | ||
}); | ||
|
||
request(app) | ||
.get('/') | ||
.expect(500) | ||
.expect(() => { | ||
assert(loggerCalled, 'structuredLogger.emit should have been called'); | ||
}) | ||
.end(done); | ||
}); | ||
}); |
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
Oops, something went wrong.