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

Commit 85573b2

Browse files
authored
add system test for the debuglet api (#187)
1 parent 35e3039 commit 85573b2

File tree

3 files changed

+73
-0
lines changed

3 files changed

+73
-0
lines changed

bin/run-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,6 @@ fi
4545

4646
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]
4747
then
48+
npm run system-test
4849
./bin/run-e2e.sh || exit 1
4950
fi

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
},
4747
"scripts": {
4848
"test": "./bin/run-test.sh",
49+
"system-test": "mocha system-test/*.js --no-timeouts --bail",
4950
"changelog": "./bin/run-changelog.sh",
5051
"coverage": "./bin/run-test.sh -c",
5152
"bump": "./bin/run-bump.sh",

system-test/test-debugletapi.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Copyright 2016 Google Inc. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var assert = require('assert');
20+
var Logger = require('@google/cloud-diagnostics-common').logger;
21+
var logger = Logger.create();
22+
23+
assert.ok(
24+
process.env.GCLOUD_PROJECT,
25+
'Need to have GCLOUD_PROJECT defined ' +
26+
'along with valid application default credentials to be able to run this ' +
27+
'test');
28+
29+
var debug = require('../')();
30+
var DebugletApi = require('../src/debugletapi.js');
31+
32+
describe('Debugletapi', function() {
33+
34+
it('should register successfully', function(done) {
35+
var debugletApi = new DebugletApi({}, debug);
36+
debugletApi.init('test-uid-1', logger, function(err) {
37+
assert.ifError(err, 'init should complete successfully');
38+
39+
debugletApi.register(function(err, body) {
40+
assert.ifError(err, 'should be able to register successfull');
41+
assert.ok(body);
42+
assert.ok(body.debuggee);
43+
assert.ok(body.debuggee.id);
44+
done();
45+
});
46+
});
47+
});
48+
49+
it('should list breakpoints', function(done) {
50+
var debugletApi = new DebugletApi({}, debug);
51+
debugletApi.init('test-uid-2', logger, function(err) {
52+
assert.ifError(err, 'init should complete successfully');
53+
54+
debugletApi.register(function(err, body) {
55+
assert.ifError(err, 'should be able to register successfull');
56+
57+
debugletApi.listBreakpoints(function(err, response, body) {
58+
assert.ifError(err, 'should successfully list breakpoints');
59+
assert.ok(body);
60+
assert.ok(body.nextWaitToken);
61+
done();
62+
});
63+
});
64+
});
65+
});
66+
67+
// To be able to write the following test we need a service for adding a
68+
// breakpoint (need the debugger API). TODO.
69+
it('should update an active breakpoint');
70+
71+
});

0 commit comments

Comments
 (0)