Skip to content

Commit

Permalink
fix docs tests for logging-winston
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Feb 8, 2017
1 parent e92454e commit 1480217
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
11 changes: 9 additions & 2 deletions packages/logging-winston/src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*!
* Copyright 2016 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,6 +14,10 @@
* limitations under the License.
*/

/*!
* @module logging-winston
*/

'use strict';

var is = require('is');
Expand Down Expand Up @@ -65,6 +69,9 @@ var STACKDRIVER_LOGGING_LEVEL_CODE_TO_NAME = {
* on-premise, or on another cloud provider, you will need to provide additional
* configuration.
*
* @constructor
* @alias module:logging-winston
*
* @param {object} options - [Configuration object](#/docs). Refer to this link
* for authentication information.
* @param {object=} options.level - The default log level. Winston will filter
Expand All @@ -83,8 +90,8 @@ var STACKDRIVER_LOGGING_LEVEL_CODE_TO_NAME = {
* [official documentation]{@link https://cloud.google.com/logging/docs/api/reference/rest/v2/MonitoredResource}.
*
* @example
* var winston = require('winston');
* var transport = require('@google-cloud/logging-winston');
* var winston = require('winston');
*
* winston.add(transport, {
* projectId: 'grape-spaceship-123',
Expand Down
7 changes: 6 additions & 1 deletion packages/speech/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,13 @@ describe('Speech', function() {

speech.api.Speech = {
streamingRecognize: function(opts) {
var requestStream = through.obj();
requestStream._write = util.noop;

assert.strictEqual(opts.timeout, expectedTimeout);
done();
setImmediate(done);

return requestStream;
}
};

Expand Down
2 changes: 1 addition & 1 deletion scripts/docs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = {
title: 'Google Cloud Logging'
},
'logging-winston': {
title: 'Google Cloud Logging Winston'
skip: true
},
monitoring: {
title: 'Google Cloud Monitoring'
Expand Down
12 changes: 12 additions & 0 deletions test/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ var FakeBluebird = function() {
return Promise;
};

// For {module:logging-winston} docs.
var fakeWinston = '{ add: function() {}, emerg: function() {} }';

var modules;

if (process.env.TEST_MODULE) {
Expand Down Expand Up @@ -204,6 +207,10 @@ function getDocs(mod) {
function createInstantiationCode(mod) {
var config = overviews[mod] || {};

if (config.skip) {
return;
}

return format(multiline.stripIndent(function() {/*
var {instanceName} = require('{path}')({config});
Expand Down Expand Up @@ -237,6 +244,10 @@ function createSnippet(mod, instantiation, method) {
/require\('google-cloud'\)/g,
'require(\'../packages/google-cloud\')'
)
.replace(
'require(\'@google-cloud/logging-winston\')',
'{}'
)
.replace(
/require\('(@google-cloud\/[^']*)/g,
'require(\'../packages/' + mod + '/node_modules/$1'
Expand All @@ -248,6 +259,7 @@ function createSnippet(mod, instantiation, method) {
.replace('require(\'express\')', FakeExpress.toString())
.replace('require(\'level\')', FakeLevel.toString())
.replace('require(\'bluebird\')', FakeBluebird.toString())
.replace('require(\'winston\')', fakeWinston)
.replace('require(\'fs\')', '(' + FakeFs.toString() + '())');
}

Expand Down

0 comments on commit 1480217

Please sign in to comment.