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

Commit

Permalink
fix stale code/test from test-controller (#213)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots committed Dec 27, 2016
1 parent cebcb69 commit c48c7db
Showing 1 changed file with 2 additions and 40 deletions.
42 changes: 2 additions & 40 deletions test/test-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,13 @@
var assert = require('assert');
var nock = require('nock');
var request = require('./auth-request.js');
var proxyquire = require('proxyquire');
var Debuggee = require('../src/debuggee.js');

// the tests in this file rely on the GCLOUD_PROJECT environment variable
// not being set
delete process.env.GCLOUD_PROJECT;

// require controller while stubbing auth to bypass authentication
//
var utils = {
getProjectNumber: function(callback) { callback(null, 'project123'); }
};
var Controller = proxyquire('../src/controller.js', {
'@google/cloud-diagnostics-common': {
logger: null,
utils: utils
}
});
var Controller = require('../src/controller.js');
var fakeDebug = {
request: request
};
Expand Down Expand Up @@ -68,33 +57,6 @@ describe('Controller API', function() {
});
});

it('should have correct version without projectId', function(done) {
var oldProjNum = utils.getProjectNumber;
utils.getProjectNumber = function(callback) {
callback(new Error(), null);
};
process.env.GCLOUD_PROJECT = 'project123';
var controller = new Controller(fakeDebug);
var scope =
nock(url)
.post(api + '/debuggees/register')
.reply(200,
{debuggee: {id: 'fake-debuggee'}, activePeriodSec: 600});
var debuggee = new Debuggee({
project: 'fake-project',
uniquifier: 'fake-id',
description: 'unit test'
});
controller.register(debuggee, function(err, result) {
assert(!err, 'not expecting an error');
assert.equal(result.debuggee.id, 'fake-debuggee');
scope.done();
delete process.env.GCLOUD_PROJECT;
utils.getProjectNumber = oldProjNum;
done();
});
});

it('should not return an error when the debuggee isDisabled',
function(done) {
var scope = nock(url)
Expand All @@ -110,7 +72,7 @@ describe('Controller API', function() {
});
var controller = new Controller(fakeDebug);
controller.register(debuggee, function(err, result) {
assert.ifError(err, 'not expected an error');
assert.ifError(err, 'not expecting an error');
assert.equal(result.debuggee.id, 'fake-debuggee');
assert.ok(result.debuggee.isDisabled);
scope.done();
Expand Down

0 comments on commit c48c7db

Please sign in to comment.