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 14, 2016
1 parent 35e3039 commit f48db93
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions bin/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ fi

if [ "${TRAVIS_PULL_REQUEST}" = "false" ]
then
npm run system-test
./bin/run-e2e.sh || exit 1
fi
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() {

it('should register successfully', function(done) {
var debugletApi = new DebugletApi({}, debug);
debugletApi.init('test-uid-1', logger, function(err) {
assert.ifError(err, 'init should complete successfully');

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);
done();
});
});
});

it('should list breakpoints', function(done) {
var debugletApi = new DebugletApi({}, debug);
debugletApi.init('test-uid-2', logger, function(err) {
assert.ifError(err, 'init should complete successfully');

debugletApi.register(function(err, body) {
assert.ifError(err, 'should be able to register successfull');

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 f48db93

Please sign in to comment.