@w-4673248@
This commit is contained in:
James Sweetman 2018-02-14 14:48:03 -08:00 коммит произвёл GitHub
Родитель 6da6f9ee67
Коммит 9bcd48dd33
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
11 изменённых файлов: 218 добавлений и 183 удалений

Просмотреть файл

@ -6,9 +6,11 @@
*/
import { ChildProcess, ExecOptions, spawn } from 'child_process';
import * as os from 'os';
import 'rxjs/add/observable/fromEvent';
import 'rxjs/add/observable/interval';
import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';
import { Subscription } from 'rxjs/Subscription';
// tslint:disable-next-line:no-var-requires
@ -43,6 +45,20 @@ export class CliCommandExecutor {
}
}
export class CompositeCliCommandExecutor {
private readonly command: Command;
public constructor(commands: Command) {
this.command = commands;
}
public execute(
cancellationToken?: CancellationToken
): CompositeCliCommandExecution {
return new CompositeCliCommandExecution(this.command, cancellationToken);
}
}
/**
* Represents a command execution (a process has already been spawned for it).
* This is tightly coupled with the execution model (child_process).
@ -58,6 +74,68 @@ export interface CommandExecution {
readonly stderrSubject: Observable<Buffer | string>;
}
export class CompositeCliCommandExecution implements CommandExecution {
private readonly exitSubject: Subject<number | undefined>;
private readonly errorSubject: Subject<Error | undefined>;
private readonly stdout: Subject<string>;
private readonly stderr: Subject<string>;
public readonly command: Command;
public readonly cancellationToken?: CancellationToken;
public readonly processExitSubject: Observable<number | undefined>;
public readonly processErrorSubject: Observable<Error | undefined>;
public readonly stdoutSubject: Observable<string>;
public readonly stderrSubject: Observable<string>;
constructor(command: Command, cancellationToken?: CancellationToken) {
this.exitSubject = new Subject();
this.errorSubject = new Subject();
this.stdout = new Subject();
this.stderr = new Subject();
this.command = command;
this.cancellationToken = cancellationToken;
this.processExitSubject = this.exitSubject.asObservable();
this.processErrorSubject = this.errorSubject.asObservable();
this.stdoutSubject = this.stdout.asObservable();
this.stderrSubject = this.stderr.asObservable();
let timerSubscriber: Subscription | null;
if (cancellationToken) {
const timer = Observable.interval(1000);
timerSubscriber = timer.subscribe(async next => {
if (cancellationToken.isCancellationRequested) {
try {
this.exitSubject.next();
} catch (e) {
console.log(e);
}
}
});
}
this.processErrorSubject.subscribe(next => {
if (timerSubscriber) {
timerSubscriber.unsubscribe();
}
});
this.processExitSubject.subscribe(next => {
if (timerSubscriber) {
timerSubscriber.unsubscribe();
}
});
}
public successfulExit() {
this.exitSubject.next(0);
}
public failureExit(e?: any) {
if (e) {
this.stderr.next(`${e}${os.EOL}`);
}
this.exitSubject.next(1);
}
}
export class CliCommandExecution implements CommandExecution {
public readonly command: Command;
public readonly cancellationToken?: CancellationToken;

Просмотреть файл

@ -18,7 +18,8 @@ export { CommandBuilder, SfdxCommandBuilder } from './commandBuilder';
export {
CliCommandExecutor,
CliCommandExecution,
CommandExecution
CommandExecution,
CompositeCliCommandExecutor
} from './commandExecutor';
export { CommandOutput } from './commandOutput';
export { LocalCommandExecution } from './localCommandExecutor';

Просмотреть файл

@ -48,9 +48,9 @@
"show_cli_success_msg_description":
"Specifies whether status messages for Salesforce CLI commands run using the VS Code command palette will appear as pop-up information messages (true) or as status bar messages (false).",
"force_start_apex_debug_logging":
"SFDX: Turn on Apex Debug Log for Replay Debugger",
"SFDX: Turn On Apex Debug Log for Replay Debugger",
"force_stop_apex_debug_logging":
"SFDX: Turn off Apex Debug Log for Replay Debugger",
"SFDX: Turn Off Apex Debug Log for Replay Debugger",
"isv_bootstrap_command_text":
"SFDX: Create and Set Up Project for ISV Debugging",

Просмотреть файл

@ -317,7 +317,6 @@ export abstract class SfdxCommandletExecutor<T>
public execute(response: ContinueResponse<T>): void {
const cancellationTokenSource = new vscode.CancellationTokenSource();
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(response.data), {
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);

Просмотреть файл

@ -8,7 +8,10 @@
import {
CliCommandExecutor,
Command,
CommandBuilder,
CommandExecution,
CommandOutput,
CompositeCliCommandExecutor,
SfdxCommandBuilder
} from '@salesforce/salesforcedx-utils-vscode/out/src/cli';
import { ContinueResponse } from '@salesforce/salesforcedx-utils-vscode/out/src/types';
@ -16,8 +19,6 @@ import * as vscode from 'vscode';
import { channelService } from '../channels';
import { APEX_CODE_DEBUG_LEVEL, VISUALFORCE_DEBUG_LEVEL } from '../constants';
import { nls } from '../messages';
import { CancellableStatusBar, taskViewService } from '../statuses';
import { showTraceFlagExpiration } from '../traceflag-time-decorator';
import {
EmptyParametersGatherer,
SfdxCommandlet,
@ -25,36 +26,35 @@ import {
SfdxWorkspaceChecker
} from './commands';
import { developerLogTraceFlag } from '.';
import { developerLogTraceFlag } from './';
export class ForceStartApexDebugLoggingExecutor extends SfdxCommandletExecutor<{}> {
private cancellationTokenSource = new vscode.CancellationTokenSource();
private cancellationToken = this.cancellationTokenSource.token;
public build(): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_start_apex_debug_logging'))
.withArg('force:data:soql:query')
.withFlag(
'--query',
"SELECT id, logtype, startdate, expirationdate, debuglevelid, debuglevel.apexcode, debuglevel.visualforce FROM TraceFlag WHERE logtype='DEVELOPER_LOG'"
)
.withArg('--usetoolingapi')
.withArg('--json')
.build();
return new CommandBuilder(
nls.localize('force_start_apex_debug_logging')
).build();
}
public attachSubExecution(execution: CommandExecution) {
channelService.streamCommandOutput(execution);
}
public async execute(response: ContinueResponse<{}>): Promise<void> {
const cancellationTokenSource = new vscode.CancellationTokenSource();
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(), {
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);
const resultPromise = new CommandOutput().getCmdResult(execution);
this.attachExecution(execution, cancellationTokenSource, cancellationToken);
const executionWrapper = new CompositeCliCommandExecutor(
this.build()
).execute(this.cancellationToken);
this.attachExecution(
executionWrapper,
this.cancellationTokenSource,
this.cancellationToken
);
try {
const result = await resultPromise;
const resultJson = JSON.parse(result);
// query traceflag
let resultJson = await this.subExecute(new ForceQueryTraceFlag().build());
if (resultJson && resultJson.result && resultJson.result.size >= 1) {
const traceflag = resultJson.result.records[0];
developerLogTraceFlag.setTraceFlagDebugLevelInfo(
@ -65,50 +65,41 @@ export class ForceStartApexDebugLoggingExecutor extends SfdxCommandletExecutor<{
traceflag.DebugLevel.ApexCode,
traceflag.DebugLevel.Visualforce
);
developerLogTraceFlag.turnOnLogging();
await this.subExecute(new UpdateDebugLevelsExecutor().build());
const updateDebugLevelsCommandlet = new SfdxCommandlet(
new SfdxWorkspaceChecker(),
new EmptyParametersGatherer(),
new UpdateDebugLevelsExecutor()
);
const promises = [updateDebugLevelsCommandlet.run()];
let updateTraceFlagCommandlet;
if (!developerLogTraceFlag.isValidDateLength()) {
developerLogTraceFlag.validateDates();
updateTraceFlagCommandlet = new SfdxCommandlet(
new SfdxWorkspaceChecker(),
new EmptyParametersGatherer(),
new UpdateTraceFlagsExecutor()
);
await this.subExecute(new UpdateTraceFlagsExecutor().build());
}
if (updateTraceFlagCommandlet) {
promises.push(updateTraceFlagCommandlet.run());
}
const updatePromise = Promise.all(promises);
await updatePromise;
} else {
const createDebuglevelCommandlet = new SfdxCommandlet(
new SfdxWorkspaceChecker(),
new EmptyParametersGatherer(),
new CreateDebugLevel()
);
await createDebuglevelCommandlet.run();
resultJson = await this.subExecute(new CreateDebugLevel().build());
const debugLevelId = resultJson.result.id;
developerLogTraceFlag.setDebugLevelInfo(debugLevelId);
const userId = await getUserId(
vscode.workspace.workspaceFolders![0].uri.fsPath
);
const createTraceFlagCommandlet = new SfdxCommandlet(
new SfdxWorkspaceChecker(),
new EmptyParametersGatherer(),
new CreateTraceFlag(userId)
);
await createTraceFlagCommandlet.run();
developerLogTraceFlag.createTraceFlagInfo();
resultJson = await this.subExecute(new CreateTraceFlag(userId).build());
developerLogTraceFlag.setTraceFlagId(resultJson.result.id);
}
// run executors to update traceflag and debug levels
// tslint:disable-next-line:no-empty
} catch (e) {}
developerLogTraceFlag.turnOnLogging();
executionWrapper.successfulExit();
} catch (e) {
executionWrapper.failureExit(e);
}
}
private async subExecute(command: Command) {
if (!this.cancellationToken.isCancellationRequested) {
const execution = new CliCommandExecutor(command, {
cwd: vscode.workspace.workspaceFolders![0].uri.fsPath
}).execute(this.cancellationToken);
this.attachSubExecution(execution);
const resultPromise = new CommandOutput().getCmdResult(execution);
const result = await resultPromise;
return JSON.parse(result);
}
}
}
@ -131,9 +122,8 @@ export async function getUserId(projectPath: string): Promise<string> {
}
export class CreateDebugLevel extends SfdxCommandletExecutor<{}> {
public build(data: {}): Command {
public build(): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_start_apex_debug_logging'))
.withArg('force:data:record:create')
.withFlag('--sobjecttype', 'DebugLevel')
.withFlag(
@ -144,31 +134,6 @@ export class CreateDebugLevel extends SfdxCommandletExecutor<{}> {
.withArg('--json')
.build();
}
public async execute(response: ContinueResponse<{}>): Promise<void> {
const cancellationTokenSource = new vscode.CancellationTokenSource();
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(response.data), {
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);
const resultPromise = new CommandOutput().getCmdResult(execution);
try {
const result = await resultPromise;
const resultJson = JSON.parse(result);
const debugLevelId = resultJson.result.id;
developerLogTraceFlag.setDebugLevelInfo(
debugLevelId,
APEX_CODE_DEBUG_LEVEL,
VISUALFORCE_DEBUG_LEVEL
);
channelService.streamCommandOutput(execution);
channelService.showChannelOutput();
CancellableStatusBar.show(execution, cancellationTokenSource);
taskViewService.addCommandExecution(execution, cancellationTokenSource);
} catch (e) {
console.log(e);
}
}
}
export class CreateTraceFlag extends SfdxCommandletExecutor<{}> {
@ -181,36 +146,26 @@ export class CreateTraceFlag extends SfdxCommandletExecutor<{}> {
public build(): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_start_apex_debug_logging'))
.withArg('force:data:record:create')
.withFlag('--sobjecttype', 'TraceFlag')
.withFlag(
'--values',
`tracedentityid='${this
.userId}' logtype=developer_log debuglevelid=${developerLogTraceFlag.getDebugLevelId()}`
.userId}' logtype=developer_log debuglevelid=${developerLogTraceFlag.getDebugLevelId()} StartDate='${developerLogTraceFlag
.getStartDate()
.toUTCString()}' ExpirationDate='${developerLogTraceFlag
.getExpirationDate()
.toUTCString()}`
)
.withArg('--usetoolingapi')
.withArg('--json')
.build();
}
public async execute(response: ContinueResponse<{}>): Promise<void> {
const cancellationTokenSource = new vscode.CancellationTokenSource();
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(), {
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);
channelService.streamCommandOutput(execution);
channelService.showChannelOutput();
CancellableStatusBar.show(execution, cancellationTokenSource);
taskViewService.addCommandExecution(execution, cancellationTokenSource);
}
}
export class UpdateDebugLevelsExecutor extends SfdxCommandletExecutor<{}> {
public build(data: {}): Command {
public build(): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_start_apex_debug_logging'))
.withArg('force:data:record:update')
.withFlag('--sobjecttype', 'DebugLevel')
.withFlag('--sobjectid', developerLogTraceFlag.getDebugLevelId())
@ -219,35 +174,14 @@ export class UpdateDebugLevelsExecutor extends SfdxCommandletExecutor<{}> {
`ApexCode=${APEX_CODE_DEBUG_LEVEL} Visualforce=${VISUALFORCE_DEBUG_LEVEL}`
)
.withArg('--usetoolingapi')
.withArg('--json')
.build();
}
public execute(response: ContinueResponse<{}>): void {
const cancellationTokenSource = new vscode.CancellationTokenSource();
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(response.data), {
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);
channelService.streamCommandOutput(execution);
channelService.showChannelOutput();
CancellableStatusBar.show(execution, cancellationTokenSource);
taskViewService.addCommandExecution(execution, cancellationTokenSource);
execution.processExitSubject.subscribe(async data => {
if (data != undefined && data.toString() === '0') {
showTraceFlagExpiration(
developerLogTraceFlag.getExpirationDate().toLocaleString()
);
}
});
}
}
export class UpdateTraceFlagsExecutor extends SfdxCommandletExecutor<{}> {
public build(data: {}): Command {
public build(): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_start_apex_debug_logging'))
.withArg('force:data:record:update')
.withFlag('--sobjecttype', 'TraceFlag')
.withFlag('--sobjectid', developerLogTraceFlag.getTraceFlagId())
@ -260,27 +194,29 @@ export class UpdateTraceFlagsExecutor extends SfdxCommandletExecutor<{}> {
.toUTCString()}'`
)
.withArg('--usetoolingapi')
.withArg('--json')
.build();
}
public execute(response: ContinueResponse<{}>): void {
const cancellationTokenSource = new vscode.CancellationTokenSource();
const cancellationToken = cancellationTokenSource.token;
const execution = new CliCommandExecutor(this.build(response.data), {
cwd: vscode.workspace.rootPath
}).execute(cancellationToken);
channelService.streamCommandOutput(execution);
channelService.showChannelOutput();
CancellableStatusBar.show(execution, cancellationTokenSource);
taskViewService.addCommandExecution(execution, cancellationTokenSource);
}
}
const workspaceChecker = new SfdxWorkspaceChecker();
const parameterGatherer = new EmptyParametersGatherer();
export class ForceQueryTraceFlag extends SfdxCommandletExecutor<{}> {
public build(): Command {
return new SfdxCommandBuilder()
.withDescription(nls.localize('force_start_apex_debug_logging'))
.withArg('force:data:soql:query')
.withFlag(
'--query',
"SELECT id, logtype, startdate, expirationdate, debuglevelid, debuglevel.apexcode, debuglevel.visualforce FROM TraceFlag WHERE logtype='DEVELOPER_LOG'"
)
.withArg('--usetoolingapi')
.withArg('--json')
.build();
}
}
export function forceStartApexDebugLogging() {
// tslint:disable-next-line:no-invalid-this
const executor = new ForceStartApexDebugLoggingExecutor();

Просмотреть файл

@ -42,5 +42,5 @@ export { forceProjectCreate } from './forceProjectCreate';
export { forceApexTriggerCreate } from './forceApexTriggerCreate';
export { forceStartApexDebugLogging } from './forceStartApexDebugLogging';
export { forceStopApexDebugLogging } from './forceStopApexDebugLogging';
import { DeveloperLogTraceFlag } from '../DeveloperLogTraceFlag';
import { DeveloperLogTraceFlag } from '../traceflag/developerLogTraceFlag';
export const developerLogTraceFlag = DeveloperLogTraceFlag.getInstance();

Просмотреть файл

@ -118,11 +118,13 @@ export const messages = {
force_project_create_open_dialog_create_label: 'Create Project',
force_apex_trigger_create_text: 'SFDX: Create Apex Trigger',
force_start_apex_debug_logging:
'SFDX: Turn on Apex Debug Log for Replay Debugger',
force_apex_debug_log_status_bar_text: 'Logging ends at %s',
'SFDX: Turn On Apex Debug Log for Replay Debugger',
force_apex_debug_log_status_bar_text:
'$(file-text) Recording detailed logs until %s',
force_apex_debug_log_status_bar_hover_text:
'Writing debug logs for Apex and Visualforce at the %s log level until %s on %s',
force_stop_apex_debug_logging:
'SFDX: Turn off Apex Debug Log for Replay Debugger',
'SFDX: Turn Off Apex Debug Log for Replay Debugger',
isv_debug_bootstrap_step1_create_project:
'SFDX: ISV Debugger Setup, Step 1 of 2: Create Project',
isv_debug_bootstrap_step1_configure_project:

Просмотреть файл

@ -6,17 +6,35 @@
*/
import { StatusBarAlignment, StatusBarItem, window } from 'vscode';
import { APEX_CODE_DEBUG_LEVEL } from './constants';
import { nls } from './messages';
let statusBarItem: StatusBarItem;
export function showTraceFlagExpiration(expirationDate: String) {
export function showTraceFlagExpiration(expirationDate: Date) {
if (!statusBarItem) {
statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 40);
}
statusBarItem.text = nls.localize(
'force_apex_debug_log_status_bar_text',
expirationDate
expirationDate.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit'
})
);
statusBarItem.tooltip = nls.localize(
'force_apex_debug_log_status_bar_hover_text',
APEX_CODE_DEBUG_LEVEL,
expirationDate.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit'
}),
expirationDate.toLocaleDateString('en-US', {
year: 'numeric',
month: 'numeric',
day: 'numeric'
})
);
statusBarItem.show();
}

Просмотреть файл

@ -4,6 +4,10 @@
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { APEX_CODE_DEBUG_LEVEL, VISUALFORCE_DEBUG_LEVEL } from '../constants';
import { showTraceFlagExpiration } from '../traceflag-time-decorator';
export class DeveloperLogTraceFlag {
private static instance: DeveloperLogTraceFlag;
private active: boolean;
@ -54,26 +58,21 @@ export class DeveloperLogTraceFlag {
public setDebugLevelInfo(
debugLevelId: string,
oldApexCodeDebugLevel: string,
oldVFDebugLevel: string
oldApexCodeDebugLevel = APEX_CODE_DEBUG_LEVEL,
oldVFDebugLevel = VISUALFORCE_DEBUG_LEVEL
) {
this.debugLevelId = debugLevelId;
this.prevApexCodeDebugLevel = oldApexCodeDebugLevel;
this.prevVFDebugLevel = oldVFDebugLevel;
}
public setTraceFlagInfo(
id: string,
startDate: string,
expirationDate: string
) {
public setTraceFlagId(id: string) {
this.traceflagId = id;
this.startDate = new Date(startDate);
this.expirationDate = new Date(expirationDate);
}
public turnOnLogging() {
this.active = true;
showTraceFlagExpiration(this.getExpirationDate());
}
public isValidDateLength() {

Просмотреть файл

@ -0,0 +1,8 @@
/*
* Copyright (c) 2017, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
export { DeveloperLogTraceFlag } from './developerLogTraceFlag';

Просмотреть файл

@ -11,6 +11,7 @@ import { developerLogTraceFlag } from '../../src/commands';
import {
CreateDebugLevel,
CreateTraceFlag,
ForceQueryTraceFlag,
ForceStartApexDebugLoggingExecutor,
UpdateDebugLevelsExecutor,
UpdateTraceFlagsExecutor
@ -54,36 +55,35 @@ describe('Force Start Apex Debug Logging', () => {
expDateStub.restore();
});
it('Should build the traceflag query for logging', async () => {
it('Should build the start logging command and only have description set', async () => {
const startLoggingExecutor = new ForceStartApexDebugLoggingExecutor();
const startLoggingCmd = startLoggingExecutor.build();
expect(startLoggingCmd.toCommand()).to.equal(
"sfdx force:data:soql:query --query SELECT id, logtype, startdate, expirationdate, debuglevelid, debuglevel.apexcode, debuglevel.visualforce FROM TraceFlag WHERE logtype='DEVELOPER_LOG' --usetoolingapi --json"
);
expect(startLoggingCmd.description).to.equal(
expect(startLoggingCmd.toCommand().trim()).to.equal(
nls.localize('force_start_apex_debug_logging')
);
});
it('Should build the traceflag query command for logging', async () => {
const queryTraceFlagsExecutor = new ForceQueryTraceFlag();
const updateTraceFlagCmd = queryTraceFlagsExecutor.build();
expect(updateTraceFlagCmd.toCommand()).to.equal(
`sfdx force:data:soql:query --query SELECT id, logtype, startdate, expirationdate, debuglevelid, debuglevel.apexcode, debuglevel.visualforce FROM TraceFlag WHERE logtype='DEVELOPER_LOG' --usetoolingapi --json`
);
});
it('Should build the traceflag update command for logging', async () => {
const updateTraceFlagsExecutor = new UpdateTraceFlagsExecutor();
const updateTraceFlagCmd = updateTraceFlagsExecutor.build({});
const updateTraceFlagCmd = updateTraceFlagsExecutor.build();
expect(updateTraceFlagCmd.toCommand()).to.equal(
`sfdx force:data:record:update --sobjecttype TraceFlag --sobjectid ${fakeTraceFlagId} --values StartDate='${startDate.toUTCString()}' ExpirationDate='${endDate.toUTCString()}' --usetoolingapi`
);
expect(updateTraceFlagCmd.description).to.equal(
nls.localize('force_start_apex_debug_logging')
`sfdx force:data:record:update --sobjecttype TraceFlag --sobjectid ${fakeTraceFlagId} --values StartDate='${startDate.toUTCString()}' ExpirationDate='${endDate.toUTCString()}' --usetoolingapi --json`
);
});
it('Should build the debuglevel update command for logging', async () => {
const updateDebugLevelsExecutor = new UpdateDebugLevelsExecutor();
const updateDebugLevelCmd = updateDebugLevelsExecutor.build({});
const updateDebugLevelCmd = updateDebugLevelsExecutor.build();
expect(updateDebugLevelCmd.toCommand()).to.equal(
`sfdx force:data:record:update --sobjecttype DebugLevel --sobjectid ${fakeDebugLevelId} --values ApexCode=${APEX_CODE_DEBUG_LEVEL} Visualforce=${VISUALFORCE_DEBUG_LEVEL} --usetoolingapi`
);
expect(updateDebugLevelCmd.description).to.equal(
nls.localize('force_start_apex_debug_logging')
`sfdx force:data:record:update --sobjecttype DebugLevel --sobjectid ${fakeDebugLevelId} --values ApexCode=${APEX_CODE_DEBUG_LEVEL} Visualforce=${VISUALFORCE_DEBUG_LEVEL} --usetoolingapi --json`
);
});
@ -91,21 +91,15 @@ describe('Force Start Apex Debug Logging', () => {
const createTraceFlagExecutor = new CreateTraceFlag('testUserId');
const createTraceFlagCmd = createTraceFlagExecutor.build();
expect(createTraceFlagCmd.toCommand()).to.equal(
`sfdx force:data:record:create --sobjecttype TraceFlag --values tracedentityid='testUserId' logtype=developer_log debuglevelid=${fakeDebugLevelId} --usetoolingapi`
);
expect(createTraceFlagCmd.description).to.equal(
nls.localize('force_start_apex_debug_logging')
`sfdx force:data:record:create --sobjecttype TraceFlag --values tracedentityid='testUserId' logtype=developer_log debuglevelid=${fakeDebugLevelId} StartDate='${startDate.toUTCString()}' ExpirationDate='${endDate.toUTCString()} --usetoolingapi --json`
);
});
it('Should build the debuglevel create command for logging', async () => {
const createDebugLevelExecutor = new CreateDebugLevel();
const createDebugLevelCmd = createDebugLevelExecutor.build({});
const createDebugLevelCmd = createDebugLevelExecutor.build();
expect(createDebugLevelCmd.toCommand()).to.equal(
`sfdx force:data:record:create --sobjecttype DebugLevel --values developername=ReplayDebuggerLevels${Date.now()} MasterLabel=ReplayDebuggerLevels${Date.now()} apexcode=${APEX_CODE_DEBUG_LEVEL} visualforce=${VISUALFORCE_DEBUG_LEVEL} --usetoolingapi --json`
);
expect(createDebugLevelCmd.description).to.equal(
nls.localize('force_start_apex_debug_logging')
);
});
});