Skip to content

Commit

Permalink
chore: move MockedResponse to nodeHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarchaud committed Oct 24, 2020
1 parent af95af1 commit a2600de
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
20 changes: 0 additions & 20 deletions packages/opentelemetry-exporter-collector/test/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { InstrumentationLibrary } from '@opentelemetry/core';
import * as assert from 'assert';
import { opentelemetryProto } from '../src/types';
import * as collectorTypes from '../src/types';
import { Stream } from 'stream';

const meterProvider = new MeterProvider({
interval: 30000,
Expand Down Expand Up @@ -667,22 +666,3 @@ export function ensureHeadersContain(
);
});
}

export class MockedResponse extends Stream {
constructor(private _code: number, private _msg?: string) {
super();
}

send(data: string) {
this.emit('data', data);
this.emit('end');
}

get statusCode() {
return this._code;
}

get statusMessage() {
return this._msg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import * as sinon from 'sinon';
import { CollectorMetricExporter } from '../../src/platform/node';
import { CollectorExporterConfigBase } from '../../src/types';
import * as collectorTypes from '../../src/types';

import { MockedResponse } from './nodeHelper';
import {
mockCounter,
mockObserver,
Expand All @@ -31,7 +31,6 @@ import {
mockValueRecorder,
ensureValueRecorderIsCorrect,
ensureObserverIsCorrect,
MockedResponse,
} from '../helper';
import { MetricRecord } from '@opentelemetry/metrics';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as sinon from 'sinon';
import { CollectorTraceExporter } from '../../src/platform/node';
import { CollectorExporterConfigBase } from '../../src/types';
import * as collectorTypes from '../../src/types';
import { MockedResponse } from '../helper';
import { MockedResponse } from './nodeHelper';

import {
ensureExportTraceServiceRequestIsSet,
Expand Down
36 changes: 36 additions & 0 deletions packages/opentelemetry-exporter-collector/test/node/nodeHelpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright The OpenTelemetry Authors
*
* 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
*
* https://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 { Stream } from 'stream';

export class MockedResponse extends Stream {
constructor(private _code: number, private _msg?: string) {
super();
}

send(data: string) {
this.emit('data', data);
this.emit('end');
}

get statusCode() {
return this._code;
}

get statusMessage() {
return this._msg;
}
}

0 comments on commit a2600de

Please sign in to comment.