This repository was archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathtest-controller.ts
129 lines (116 loc) · 4.46 KB
/
test-controller.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright 2016 Google LLC
//
// 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.
import * as assert from 'assert';
// import {describe, it} from 'mocha';
assert.ok(
process.env.GCLOUD_PROJECT,
'Need to have GCLOUD_PROJECT defined to be able to run this test'
);
assert.ok(
process.env.GOOGLE_APPLICATION_CREDENTIALS,
'Need to have GOOGLE_APPLICATION_CREDENTIALS defined to be able to run ' +
'this test'
);
// import * as stackdriver from '../src/types/stackdriver';
// import {Debuggee} from '../src/debuggee';
// import {PackageInfo} from '../src/agent/debuglet';
// import {defaultConfig as DEFAULT_CONFIG} from '../src/agent/config';
// import {MockLogger} from '../test/mock-logger';
// const packageInfo: PackageInfo = {
// name: 'SomeName',
// version: 'SomeVersion',
// };
// const agentVersion = `${packageInfo.name}/client/${packageInfo.version}`;
/*
TODO: Write tests that work for Firebase backend, if they aren't covered by E2E.
describe('Controller', function () {
this.timeout(60 * 1000);
const logger = new MockLogger();
it('should register successfully', done => {
const controller = new OnePlatformController(debug, DEFAULT_CONFIG, logger);
const debuggee = new Debuggee({
project: process.env.GCLOUD_PROJECT,
uniquifier: 'test-uid-' + Date.now(),
description: 'this is a system test',
agentVersion,
});
controller.register(debuggee, (err, maybeBody) => {
assert.ifError(err);
assert.ok(maybeBody);
const body = maybeBody as {debuggee: Debuggee};
assert.ok(body.debuggee);
assert.ok(body.debuggee.id);
done();
});
});
it('should list breakpoints', done => {
const controller = new OnePlatformController(debug, DEFAULT_CONFIG, logger);
const debuggee = new Debuggee({
project: process.env.GCLOUD_PROJECT,
uniquifier: 'test-uid-' + Date.now(),
description: 'this is a system test',
agentVersion,
});
// TODO: Determine if the body parameter should be used.
controller.register(debuggee, err1 => {
assert.ifError(err1);
// TODO: Determine if the response parameter should be used.
controller.listBreakpoints(debuggee, (err2, response, maybeBody) => {
assert.ifError(err2);
assert.ok(maybeBody);
const body2 = maybeBody as stackdriver.ListBreakpointsResponse;
assert.ok(body2.nextWaitToken);
done();
});
});
});
it('should pass success on timeout', done => {
this.timeout(100000);
const controller = new OnePlatformController(debug, DEFAULT_CONFIG, logger);
const debuggee = new Debuggee({
project: process.env.GCLOUD_PROJECT,
uniquifier: 'test-uid-' + Date.now(),
description: 'this is a system test',
agentVersion,
});
// TODO: Determine if the body parameter should be used.
controller.register(debuggee, err => {
assert.ifError(err);
// First list should set the wait token
// TODO: Determine if the response parameter should be used.
controller.listBreakpoints(debuggee, (err1, response1, maybeBody1) => {
assert.ifError(err1);
assert.ok(maybeBody1);
const body1 = maybeBody1 as stackdriver.ListBreakpointsResponse;
assert.ok(body1.nextWaitToken);
// Second list should block until the wait timeout
// TODO: Determine if the response parameter should be used.
controller.listBreakpoints(debuggee, (err2, response2, maybeBody2) => {
assert.ifError(err2);
assert.ok(maybeBody2);
const body2 = maybeBody2 as stackdriver.ListBreakpointsResponse;
assert.ok(body2.nextWaitToken);
// waitExpired will only be set if successOnTimeout was given
// correctly
assert.ok(body2.waitExpired);
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');
});
*/