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

Commit

Permalink
merge configs using a deep copy (#240)
Browse files Browse the repository at this point in the history
We were losing the default values of some properties previously.
  • Loading branch information
ofrobots committed Feb 11, 2017
1 parent 75974f5 commit 21a8f5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/agent/debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Debuglet.prototype.normalizeConfig_ = function(config) {
}
};

config = extend({}, defaultConfig, config, envConfig);
config = extend(true, {}, defaultConfig, config, envConfig);

if (config.keyFilename || config.credentials || config.projectId) {
throw new Error('keyFilename, projectId or credentials should be provided' +
Expand Down
14 changes: 14 additions & 0 deletions test/test-debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ 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);

// 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);
});

it('should not start when projectId is not available', function(done) {
this.timeout(8000);
var debug = require('../src/debug.js')();
Expand Down

0 comments on commit 21a8f5a

Please sign in to comment.