From da1f6d0a2a2fdd6085ccc0f3c0129911e7bfd0e2 Mon Sep 17 00:00:00 2001 From: Ali Ijaz Sheikh Date: Tue, 13 Dec 2016 15:29:15 -0800 Subject: [PATCH] add system test for the debuglet api --- bin/run-test.sh | 1 + package.json | 1 + system-test/test-debugletapi.js | 71 +++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 system-test/test-debugletapi.js diff --git a/bin/run-test.sh b/bin/run-test.sh index 04778d36..0fd214b3 100755 --- a/bin/run-test.sh +++ b/bin/run-test.sh @@ -45,5 +45,6 @@ fi if [ "${TRAVIS_PULL_REQUEST}" = "false" ] then + npm run system-test ./bin/run-e2e.sh || exit 1 fi diff --git a/package.json b/package.json index 28c1c503..72e4e134 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/system-test/test-debugletapi.js b/system-test/test-debugletapi.js new file mode 100644 index 00000000..285a37b1 --- /dev/null +++ b/system-test/test-debugletapi.js @@ -0,0 +1,71 @@ +/** + * Copyright 2016 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'); + +});