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

Commit bf33d9c

Browse files
committed
Refactoring test classes to the new clases names
2 parents 7af710f + 3cf908a commit bf33d9c

5 files changed

Lines changed: 45 additions & 37 deletions

File tree

packages/opencensus-core/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "OpenCensus is a toolkit for collecting application performance and behavior data.",
55
"main": "build/src/index.js",
66
"types": "build/src/index.d.js",
7+
"repository": "census-instrumentation/opencensus-node",
78
"scripts": {
89
"test": "npm run script run-unit-tests",
910
"compile-all": "npm run script compile-auto",

packages/opencensus-core/src/trace/instrumentation/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17-
export interface Plugin <TM> {
18-
applyPatch(module: any, manager: TM, version: string): void;
17+
export interface Plugin <T> {
18+
applyPatch(module: any, tracer: T, version: string): void;
1919
}
2020

21-
export abstract class BasePlugin <TM> {
21+
export abstract class BasePlugin <T> {
2222

2323
public module: any;
2424
public moduleName: string;
25-
public traceManager: TM;
25+
public tracer: T;
2626
public version: string;
2727

2828
constructor (moduleName: string) {
2929
this.moduleName = moduleName;
3030
}
3131

32-
setPluginContext(http: any, traceManager: TM, version: string) {
32+
setPluginContext(http: any, tracer: T, version: string) {
3333
this.module = http;
34-
this.traceManager = traceManager;
34+
this.tracer = tracer;
3535
this.version = version;
3636
}
3737

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Span } from '../src/trace/span';
18-
import { Trace } from '../src/trace/trace';
17+
import { Span } from '../src/trace/model/span';
18+
import { Trace } from '../src/trace/model/trace';
1919

2020
var assert = require('assert');
2121

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { Trace } from '../src/trace/trace';
18-
import { Span } from '../src/trace/span';
17+
import { Trace } from '../src/trace/model/trace';
18+
import { Span } from '../src/trace/model/span';
1919

2020
let assert = require('assert');
2121

packages/opencensus-core/test/test-tracemanager.ts renamed to packages/opencensus-core/test/test-tracer.ts

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,55 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { TraceManager } from '../src/trace/tracemanager';
18-
import { Trace } from '../src/trace/trace';
19-
import { Span } from '../src/trace/span';
17+
import { Tracer } from '../src/trace/model/tracer';
18+
import { Trace } from '../src/trace/model/trace';
19+
import { Span } from '../src/trace/model/span';
20+
import { Exporter } from '../src/exporters/exporter';
2021

2122
let assert = require('assert');
2223

23-
describe('TraceManager', function () {
24-
describe('new TraceManager()', function () {
25-
it('should be a TraceManager instance', function () {
26-
let traceManager = new TraceManager();
27-
assert.ok(traceManager instanceof TraceManager);
24+
class NoopExporter implements Exporter {
25+
emit(trace: Trace) {}
26+
}
27+
28+
let noopExporter = new NoopExporter();
29+
30+
describe('Tracer', function () {
31+
describe('new Tracer()', function () {
32+
it('should be a Tracer instance', function () {
33+
let tracer = new Tracer(noopExporter);
34+
assert.ok(tracer instanceof Tracer);
2835
});
2936
});
3037

3138
describe('start()', function () {
32-
let traceManager = new TraceManager();
33-
let traceManagerStarted = traceManager.start();
39+
let tracer = new Tracer(noopExporter);
40+
let tracerStarted = tracer.start();
3441

35-
it('should return a TraceManager instance', function () {
36-
assert.ok(traceManagerStarted instanceof TraceManager);
42+
it('should return a tracer instance', function () {
43+
assert.ok(tracerStarted instanceof Tracer);
3744
});
3845

3946
it('should set true on active property', function () {
40-
assert.ok(traceManagerStarted.active);
47+
assert.ok(tracerStarted.active);
4148
});
4249
});
4350

4451
describe('startTrace()', function () {
45-
let traceManager;
52+
let tracer;
4653
let trace;
4754

4855
before(() => {
49-
traceManager = new TraceManager();
50-
trace = traceManager.startTrace();
56+
tracer = new Tracer(noopExporter);
57+
trace = tracer.startTrace();
5158
})
5259

5360
it('should return a Trace instance', function () {
5461
assert.ok(trace instanceof Trace);
5562
});
5663

5764
it('the new trace was set as current trace', function () {
58-
assert.equal(traceManager.currentTrace.id, trace.id);
65+
assert.equal(tracer.currentTrace.id, trace.id);
5966
});
6067

6168
it('the new trace was started', function () {
@@ -65,26 +72,26 @@ describe('TraceManager', function () {
6572

6673
describe('endTrace()', function () {
6774
it('the current trace was ended', function () {
68-
let traceManager = new TraceManager();
69-
let trace = traceManager.startTrace();
70-
traceManager.endTrace();
75+
let tracer = new Tracer(noopExporter);
76+
let trace = tracer.startTrace();
77+
tracer.endTrace();
7178
assert.ok(trace.ended);
7279
});
7380
});
7481

7582
describe('clearCurrentTrace()', function () {
7683
it('the current trace is null', function () {
77-
let traceManager = new TraceManager();
78-
let trace = traceManager.startTrace();
79-
traceManager.clearCurrentTrace();
80-
assert.ok(traceManager.currentTrace == null);
84+
let tracer = new Tracer(noopExporter);
85+
let trace = tracer.startTrace();
86+
tracer.clearCurrentTrace();
87+
assert.ok(tracer.currentTrace == null);
8188
});
8289
});
8390

8491
describe('startSpan()', function () {
85-
let traceManager = new TraceManager();
86-
let trace = traceManager.startTrace();
87-
let span = traceManager.startSpan("spanName", "spanType");
92+
let tracer = new Tracer(noopExporter);
93+
let trace = tracer.startTrace();
94+
let span = tracer.startSpan("spanName", "spanType");
8895
it('should return a Span instance', function () {
8996
assert.ok(span instanceof Span);
9097
});

0 commit comments

Comments
 (0)