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

Commit

Permalink
add system test for the debuglet api
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots committed Dec 13, 2016
1 parent 35e3039 commit 32afa8f
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
},
"scripts": {
"test": "./bin/run-test.sh",
"system-test": "mocha system-test/*.js --no-timeouts --bail",
"changelog": "./bin/run-changelog.sh",
"coverage": "./bin/run-test.sh -c",
"bump": "./bin/run-bump.sh",
Expand Down
71 changes: 71 additions & 0 deletions system-test/test-debugletapi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright 2014 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

var assert = require('assert');
var Logger = require('@google/cloud-diagnostics-common').logger;
var logger = Logger.create();

assert.ok(
process.env.GCLOUD_PROJECT,
'Need to have GCLOUD_PROJECT defined ' +
'along with valid application default credentials to be able to run this ' +
'test');

var debug = require('../')();
var DebugletApi = require('../src/debugletapi.js');

describe('Debugletapi', function() {
var debugletApi = new DebugletApi({}, debug);
var debuggee = null;

before(function(done) {
debugletApi.init('test-uid', logger, function(err) {
assert.ifError(err, 'init should complete successfully');
done();
});
});

it('should register successfully', function(done) {
debugletApi.register(function(err, body) {
assert.ifError(err, 'should be able to register successfull');
assert.ok(body);
assert.ok(body.debuggee);
assert.ok(body.debuggee.id);
debuggee = body.debuggee;
done();
});
});

it('should list breakpoints', function(done) {
if (!debuggee) {
// Dependent on the previous test passing.
this.skip();
done();
}
debugletApi.listBreakpoints(function(err, response, body) {
assert.ifError(err, 'should successfully list breakpoints');
assert.ok(body);
assert.ok(body.nextWaitToken);
done();
});
});

// To be able to write the following test we need a service for adding a
// breakpoint (need the debugger API). TODO.
it('should update an active breakpoint');
});

0 comments on commit 32afa8f

Please sign in to comment.