forked from googleapis/cloud-debug-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-state.ts
53 lines (47 loc) · 1.9 KB
/
test-state.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
// Copyright 2017 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';
import * as utils from '../src/agent/util/utils';
import * as proxyquire from 'proxyquire';
const describeFn = utils.satisfies(process.version, '>=10')
? describe.skip
: describe;
describeFn('state', () => {
// Testing of state.js is driven through test-v8debugapi.js. There are
// minimal unit tests here.
it('should have assertions enabled', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const state = require('../src/agent/state/legacy-state');
// this test makes sure that the necessary environment variables to enable
// asserts are present during testing. Use run-tests.sh, or export
// CLOUD_DEBUG_ASSERTIONS=1 to make sure this test passes.
if (!process.env.CLOUD_DEBUG_ASSERTIONS) {
console.log(
'This test requires the enviornment variable ' +
'CLOUD_DEBUG_ASSERTIONS to be set in order to pass'
);
}
assert.throws(() => {
state.testAssert();
});
});
it('should not throw if vm is not an object', () => {
// test for
// https://github.com/googleapis/cloud-debug-nodejs/issues/503
// eslint-disable-next-line @typescript-eslint/no-var-requires
const state = proxyquire('../src/agent/state/legacy-state', {vm: false});
assert.ok(state);
});
});