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

Commit 2d45b8c

Browse files
author
Matt Loring
committed
Regression test for #50 on GH
Ensures that errors occuring when a breakpoint is set are reported to the api. Fixes #50
1 parent df8b6f6 commit 2d45b8c

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/standalone/test-debuglet.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,53 @@ describe(__filename, function(){
156156

157157
it('should add a breakpoint');
158158

159+
it('should report error on breakpoint set', function(done) {
160+
var debuglet = new Debuglet(
161+
config, logger.create(config.logLevel, '@google/cloud-debug'));
162+
163+
process.env.GCLOUD_PROJECT_NUM=0;
164+
165+
var bp = {
166+
id: 'test',
167+
location: { path: 'fixtures/foo', line: 2 }
168+
};
169+
170+
var API = 'https://clouddebugger.googleapis.com';
171+
172+
var scope = nock(API)
173+
.post('/v2/controller/debuggees/register')
174+
.reply(200, {
175+
debuggee: {
176+
id: 'bar'
177+
}
178+
})
179+
.get('/v2/controller/debuggees/bar/breakpoints')
180+
.reply(200, {
181+
breakpoints: [bp]
182+
})
183+
.put('/v2/controller/debuggees/bar/breakpoints/test', function(body) {
184+
var status = body.breakpoint.status;
185+
return status.isError &&
186+
status.description.format.indexOf('Only files with .js extensions') !== -1;
187+
})
188+
.reply(200);
189+
190+
debuglet.once('started', function() {
191+
debuglet.debugletApi_.request_ = request; // Avoid authing.
192+
});
193+
debuglet.once('registered', function(id) {
194+
assert(id === 'bar');
195+
setTimeout(function() {
196+
assert(!debuglet.activeBreakpointMap_.test);
197+
debuglet.stop();
198+
scope.done();
199+
done();
200+
}, 200);
201+
});
202+
203+
debuglet.start();
204+
});
205+
159206
it('should expire stale breakpoints', function(done) {
160207
var oldTimeout = config.breakpointExpirationSec;
161208
config.breakpointExpirationSec = 1;

0 commit comments

Comments
 (0)