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

Commit

Permalink
Regression test for #50 on GH
Browse files Browse the repository at this point in the history
Ensures that errors occuring when a breakpoint is set are reported to
the api.

Fixes #50
  • Loading branch information
Matt Loring committed Jan 11, 2016
1 parent df8b6f6 commit 2d45b8c
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/standalone/test-debuglet.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,53 @@ describe(__filename, function(){

it('should add a breakpoint');

it('should report error on breakpoint set', function(done) {
var debuglet = new Debuglet(
config, logger.create(config.logLevel, '@google/cloud-debug'));

process.env.GCLOUD_PROJECT_NUM=0;

var bp = {
id: 'test',
location: { path: 'fixtures/foo', line: 2 }
};

var API = 'https://clouddebugger.googleapis.com';

var scope = nock(API)
.post('/v2/controller/debuggees/register')
.reply(200, {
debuggee: {
id: 'bar'
}
})
.get('/v2/controller/debuggees/bar/breakpoints')
.reply(200, {
breakpoints: [bp]
})
.put('/v2/controller/debuggees/bar/breakpoints/test', function(body) {
var status = body.breakpoint.status;
return status.isError &&
status.description.format.indexOf('Only files with .js extensions') !== -1;
})
.reply(200);

debuglet.once('started', function() {
debuglet.debugletApi_.request_ = request; // Avoid authing.
});
debuglet.once('registered', function(id) {
assert(id === 'bar');
setTimeout(function() {
assert(!debuglet.activeBreakpointMap_.test);
debuglet.stop();
scope.done();
done();
}, 200);
});

debuglet.start();
});

it('should expire stale breakpoints', function(done) {
var oldTimeout = config.breakpointExpirationSec;
config.breakpointExpirationSec = 1;
Expand Down

0 comments on commit 2d45b8c

Please sign in to comment.