Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 8c9102d

Browse files
added new tests in test-trace
1 parent f482e37 commit 8c9102d

2 files changed

Lines changed: 32 additions & 42 deletions

File tree

packages/opencensus-core/scripts/index.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -68,40 +68,6 @@ async function run(steps: string[]) {
6868
timeout: 4000
6969
});
7070
break;
71-
case 'run-unit-tests-with-coverage':
72-
await runTests({
73-
includeGlobs: [
74-
`${BUILD_DIRECTORY}/test/test-*.js`,
75-
`${BUILD_DIRECTORY}/test/plugins/test-*.js`
76-
],
77-
excludeGlobs: unitTestExcludeGlobs,
78-
rootDir: BUILD_DIRECTORY,
79-
coverage: true,
80-
timeout: 4000
81-
});
82-
break;
83-
case 'run-system-tests':
84-
await spawnP(
85-
'npm', ['install'], { cwd: 'system-test' }
86-
);
87-
if (CI_PULL_REQUEST && !(await existsP('node-team-test-d0b0be11c23d.json'))) {
88-
console.log('> Not running system tests in PRs');
89-
} else {
90-
await runTests({
91-
includeGlobs: [
92-
`system-test/*.js`,
93-
],
94-
rootDir: '.',
95-
coverage: false
96-
});
97-
}
98-
break;
99-
case 'report-coverage':
100-
await reportCoverage();
101-
break;
102-
case 'test-non-interference':
103-
await testNonInterference();
104-
break;
10571
default:
10672
console.log(`> ${step}: not found`);
10773
break;

packages/opencensus-core/test/test-trace.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,24 @@ import { Span } from '../src/trace/span';
44
let assert = require('assert');
55

66
describe('Trace', function () {
7-
let trace = new Trace();
8-
9-
describe('new Trace()', function () {
10-
it('should be a Trace instance', function () {
7+
describe('new Trace()', function () {
8+
it('should be a Trace instance', function () {
9+
let trace = new Trace();
1110
assert.ok(trace instanceof Trace);
1211
});
1312
});
1413

1514
describe('start()', function () {
1615
it('trace was started', function () {
17-
trace.start()
16+
let trace = new Trace();
17+
trace.start();
1818
assert.ok(trace.started);
1919
});
2020
});
2121

2222
describe('startSpan()', function () {
23+
let trace = new Trace();
24+
trace.start()
2325
let span = trace.startSpan("spanName", "spanType");
2426
it('should be a Span instance', function () {
2527
assert.ok(span instanceof Span);
@@ -32,14 +34,36 @@ describe('Trace', function () {
3234

3335
describe('end()', function () {
3436
it('trace was ended', function () {
37+
let trace = new Trace();
38+
trace.start()
3539
trace.end();
3640
assert.ok(trace.ended);
3741
});
3842
});
3943

40-
describe('startSpan() after ended trace', function () {
41-
it('should throws an exception', function () {
42-
assert.throws(() => trace.startSpan("spanName", "spanType"));
44+
describe('end() before trace started', function () {
45+
it('trace was not ended', function () {
46+
let trace = new Trace();
47+
trace.end();
48+
assert.ok(!trace.ended);
49+
});
50+
});
51+
52+
describe('startSpan() before trace started', function () {
53+
it('should return null', function () {
54+
let trace = new Trace();
55+
let span = trace.startSpan("spanName", "spanType");
56+
assert.ok(span == null);
57+
});
58+
});
59+
60+
describe('startSpan() after trace ended', function () {
61+
it('should return null', function () {
62+
let trace = new Trace();
63+
trace.start()
64+
trace.end();
65+
let span = trace.startSpan("spanName", "spanType");
66+
assert.ok(span == null);
4367
});
4468
});
4569

0 commit comments

Comments
 (0)