|
| 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