Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
improve normalizeConfig test (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots authored Feb 12, 2017
1 parent 21a8f5a commit ce7ce0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/agent/debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module.exports = Debuglet;
*/
function Debuglet(debug, config) {
/** @private {object} */
this.config_ = this.normalizeConfig_(config);
this.config_ = Debuglet.normalizeConfig_(config);

/** @private {Debug} */
this.debug_ = debug;
Expand Down Expand Up @@ -139,7 +139,7 @@ function Debuglet(debug, config) {

util.inherits(Debuglet, EventEmitter);

Debuglet.prototype.normalizeConfig_ = function(config) {
Debuglet.normalizeConfig_ = function(config) {
var envConfig = {
logLevel: process.env.GCLOUD_DEBUG_LOGLEVEL,
serviceContext: {
Expand Down
8 changes: 3 additions & 5 deletions test/test-debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,15 @@ describe('Debuglet', function() {
afterEach(function() { nock.cleanAll(); });

it('should merge config correctly', function() {
var debug = require('../src/debug.js')();

var testValue = 2 * defaultConfig.capture.maxExpandFrames;
var config = {capture: {maxExpandFrames: testValue}};
var debuglet = new Debuglet(debug, config);

var mergedConfig = Debuglet.normalizeConfig_(config);
var compareConfig = Debuglet.normalizeConfig_();
// The actual config should be exactly defaultConfig with only
// maxExpandFrames adjusted.
var compareConfig = extend(true, {}, defaultConfig);
compareConfig.capture.maxExpandFrames = testValue;
assert.deepEqual(debuglet.config_, compareConfig);
assert.deepEqual(mergedConfig, compareConfig);
});

it('should not start when projectId is not available', function(done) {
Expand Down

0 comments on commit ce7ce0b

Please sign in to comment.