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

Commit 80cd5a1

Browse files
authored
Remove duplicate isDisabled logic from controller (#206)
The debuglet also has the same isDisabled check. Arguably the controller shouldn't be doing this check at all because we do get a valid debuggee.id back from the service and we should faithfully report that to the client of the Controller interface. Business logic to deal with a disabled debuggee belongs in the agent.
1 parent 2ec1732 commit 80cd5a1

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

src/controller.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ Controller.prototype.register = function(debuggee, callback) {
6464
new Error('unable to register, statusCode ' + response.statusCode));
6565
} else if (!body.debuggee) {
6666
callback(new Error('invalid response body from server'));
67-
} else if (body.debuggee.isDisabled) {
68-
callback('Debuggee is disabled on server');
6967
} else {
7068
debuggee.id = body.debuggee.id;
7169
callback(null, body);

test/test-controller.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,28 @@ describe('Controller API', function() {
9595
});
9696
});
9797

98-
it('should return error when debuggee is disabled', function(done) {
99-
var scope = nock(url)
100-
.post(api + '/debuggees/register')
101-
.reply(200, {
102-
debuggee: {
103-
id: 'fake-debuggee',
104-
isDisabled: true
105-
},
106-
activePeriodSec: 600,
107-
});
108-
var debuggee = new Debuggee({
109-
project: 'fake-project',
110-
uniquifier: 'fake-id',
111-
description: 'unit test'
112-
});
113-
var controller = new Controller(fakeDebug);
114-
controller.register(debuggee, function(err/*, result*/) {
115-
assert(err, 'expected an error');
116-
scope.done();
117-
done();
118-
});
119-
});
98+
it('should not return an error when the debuggee isDisabled',
99+
function(done) {
100+
var scope = nock(url)
101+
.post(api + '/debuggees/register')
102+
.reply(200, {
103+
debuggee: {id: 'fake-debuggee', isDisabled: true},
104+
activePeriodSec: 600,
105+
});
106+
var debuggee = new Debuggee({
107+
project: 'fake-project',
108+
uniquifier: 'fake-id',
109+
description: 'unit test'
110+
});
111+
var controller = new Controller(fakeDebug);
112+
controller.register(debuggee, function(err, result) {
113+
assert.ifError(err, 'not expected an error');
114+
assert.equal(result.debuggee.id, 'fake-debuggee');
115+
assert.ok(result.debuggee.isDisabled);
116+
scope.done();
117+
done();
118+
});
119+
});
120120

121121
});
122122

0 commit comments

Comments
 (0)