Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulacamargo25 committed Jun 4, 2024
1 parent 17f3dfe commit 44193a8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/extension/telemetry/reporter.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import TelemetryReporter from "@vscode/extension-telemetry";
import { AppinsightsKey, isTestExecution } from "../common/constants";
import TelemetryReporter from '@vscode/extension-telemetry';
import { AppinsightsKey, isTestExecution } from '../common/constants';

export function getTelemetryReporter(telemetryReporter: TelemetryReporter | undefined) {
if (!isTestExecution() && telemetryReporter) {
Expand Down
14 changes: 5 additions & 9 deletions src/test/unittest/adapter/factory.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { expect, use } from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
import * as path from 'path';
import * as sinon from 'sinon';
// import rewiremock from 'rewiremock';
import { SemVer } from 'semver';
import { instance, mock, when } from 'ts-mockito';
import { DebugAdapterExecutable, DebugAdapterServer, DebugConfiguration, DebugSession, WorkspaceFolder } from 'vscode';
Expand Down Expand Up @@ -37,7 +36,6 @@ suite('Debugging - Adapter Factory', () => {
let getInterpretersStub: sinon.SinonStub;
let getInterpreterDetailsStub: sinon.SinonStub;
let hasInterpretersStub: sinon.SinonStub;
// let sendTelemetryEventStub: sinon.SinonStub;
let getTelemetryReporterStub: sinon.SinonStub;
let reporter: any;

Expand Down Expand Up @@ -78,7 +76,6 @@ suite('Debugging - Adapter Factory', () => {
getInterpretersStub = sinon.stub(pythonApi, 'getInterpreters');
getInterpreterDetailsStub = sinon.stub(pythonApi, 'getInterpreterDetails');
hasInterpretersStub = sinon.stub(pythonApi, 'hasInterpreters');
// sendTelemetryEventStub = sinon.stub(telemetry, 'sendTelemetryEvent');
getTelemetryReporterStub = sinon.stub(telemetryReporter, 'getTelemetryReporter');

when(
Expand All @@ -93,10 +90,9 @@ suite('Debugging - Adapter Factory', () => {
teardown(() => {
process.env.VSC_PYTHON_UNIT_TEST = oldValueOfVSC_PYTHON_UNIT_TEST;
process.env.VSC_PYTHON_CI_TEST = oldValueOfVSC_PYTHON_CI_TEST;
reporter.properties = [];
reporter.eventNames = [];
reporter.measures = [];
// rewiremock.disable();
Reporter.properties = [];
Reporter.eventNames = [];
Reporter.measures = [];
telemetry.clearTelemetryReporter();
sinon.restore();
});
Expand Down Expand Up @@ -265,14 +261,14 @@ suite('Debugging - Adapter Factory', () => {
assert.deepStrictEqual(descriptor, debugExecutable);
});

test.only('Send attach to local process telemetry if attaching to a local process', async () => {
test('Send attach to local process telemetry if attaching to a local process', async () => {
const session = createSession({ request: 'attach', processId: 1234 });
getInterpreterDetailsStub.resolves({ path: [interpreter.path] });
resolveEnvironmentStub.withArgs(interpreter.path).resolves(interpreter);

await factory.createDebugAdapterDescriptor(session, nodeExecutable);

assert.ok(reporter.eventNames.includes(EventName.DEBUGGER_ATTACH_TO_LOCAL_PROCESS));
assert.ok(Reporter.eventNames.includes(EventName.DEBUGGER_ATTACH_TO_LOCAL_PROCESS));
});

test("Don't send any telemetry if not attaching to a local process", async () => {
Expand Down

0 comments on commit 44193a8

Please sign in to comment.