-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update usage of '.sfdx' dir in isvdebugging #4521
Changes from 10 commits
d8cb4ff
026b65c
6d0d7f8
7c9418a
e31b2fa
dcd8635
ca25580
10a623c
f267555
fb31e80
d41019e
4d24cf1
10721ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
//eslint:disable-next-line:no-var-requires | ||
const baseConfig = require('../../config/jest.base.config'); | ||
|
||
module.exports = Object.assign({}, baseConfig); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ import { | |
} from '@salesforce/source-deploy-retrieve/lib/src/client/types'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some touches to get jest unit tests working in core. |
||
import { join } from 'path'; | ||
import * as vscode from 'vscode'; | ||
import { BaseDeployExecutor } from '.'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So doing an import like this results in scanning all things exported from the index.ts file. Which can lead to complications in unit testing. Updated to pull directly from the file where exported instead. |
||
import { channelService, OUTPUT_CHANNEL } from '../channels'; | ||
import { PersistentStorageService } from '../conflict/persistentStorageService'; | ||
import { TELEMETRY_METADATA_COUNT } from '../constants'; | ||
|
@@ -36,6 +35,7 @@ import { nls } from '../messages'; | |
import { DeployQueue } from '../settings'; | ||
import { SfdxPackageDirectories } from '../sfdxProject'; | ||
import { OrgAuthInfo } from '../util'; | ||
import { BaseDeployExecutor } from './baseDeployCommand'; | ||
import { createComponentCount, formatException } from './util'; | ||
|
||
type DeployRetrieveResult = DeployResult | RetrieveResult; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,12 @@ | |
* 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 { | ||
Command, | ||
SfdxCommandBuilder | ||
} from '@salesforce/salesforcedx-utils-vscode'; | ||
import { ContinueResponse } from '@salesforce/salesforcedx-utils-vscode'; | ||
import { ContinueResponse, SfdxCommandBuilder } from '@salesforce/salesforcedx-utils-vscode'; | ||
import { ComponentSet } from '@salesforce/source-deploy-retrieve'; | ||
import { join } from 'path'; | ||
import * as vscode from 'vscode'; | ||
import { channelService } from '../channels'; | ||
import { | ||
ConflictDetectionMessages, | ||
TimestampConflictChecker | ||
} from '../commands/util/postconditionCheckers'; | ||
import { nls } from '../messages'; | ||
|
@@ -23,7 +18,7 @@ import { SfdxPackageDirectories } from '../sfdxProject'; | |
import { telemetryService } from '../telemetry'; | ||
import { workspaceUtils } from '../util'; | ||
import { DeployExecutor } from './baseDeployRetrieve'; | ||
import { FilePathGatherer, SfdxCommandlet, SfdxWorkspaceChecker } from './util'; | ||
import { ConflictDetectionMessages, FilePathGatherer, SfdxCommandlet, SfdxWorkspaceChecker } from './util'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ran an organize imports. quite a few unused here. |
||
|
||
export class LibrarySourceDeployManifestExecutor extends DeployExecutor< | ||
string | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ import { | |
CommandOutput, | ||
ContinueResponse, | ||
ParametersGatherer, | ||
projectPaths, | ||
SfdxCommandBuilder | ||
} from '@salesforce/salesforcedx-utils-vscode'; | ||
import { SpawnOptions } from 'child_process'; | ||
|
@@ -53,19 +54,21 @@ export interface InstalledPackageInfo { | |
versionNumber: string; | ||
} | ||
|
||
export const ISVDEBUGGER = 'isvdebuggermdapitmp'; | ||
export const INSTALLED_PACKAGES = 'installed-packages'; | ||
export const PACKAGE_XML = 'package.xml'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should update the below paths to use these constants. |
||
|
||
export class IsvDebugBootstrapExecutor extends SfdxCommandletExecutor<{}> { | ||
public readonly relativeMetdataTempPath = path.join( | ||
'.sfdx', | ||
'tools', | ||
projectPaths.relativeToolsFolder(), | ||
'isvdebuggermdapitmp' | ||
); | ||
public readonly relativeApexPackageXmlPath = path.join( | ||
this.relativeMetdataTempPath, | ||
'package.xml' | ||
); | ||
public readonly relativeInstalledPackagesPath = path.join( | ||
'.sfdx', | ||
'tools', | ||
projectPaths.relativeToolsFolder(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize adding a full blown jest unit test suite for this file is probably more lift then is worthwhile for the work being addressed, but you would add a test(s) to verify the |
||
'installed-packages' | ||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright (c) 2022, 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 | ||
*/ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So for these two exports they were originally in |
||
export interface ConflictDetectionMessages { | ||
warningMessageKey: string; | ||
commandHint: (input: string | string[]) => string; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (c) 2022, 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 | ||
*/ | ||
|
||
import { CancelResponse, ContinueResponse, PostconditionChecker } from '@salesforce/salesforcedx-utils-vscode'; | ||
|
||
export class EmptyPostChecker implements PostconditionChecker<any> { | ||
public async check( | ||
inputs: ContinueResponse<any> | CancelResponse | ||
): Promise<ContinueResponse<any> | CancelResponse> { | ||
return inputs; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,27 +7,19 @@ | |
import { | ||
CliCommandExecutor, | ||
Command, | ||
CommandExecution | ||
} from '@salesforce/salesforcedx-utils-vscode'; | ||
import { | ||
Measurements, | ||
Properties, | ||
TelemetryData | ||
} from '@salesforce/salesforcedx-utils-vscode'; | ||
import { | ||
ContinueResponse, | ||
ParametersGatherer, | ||
CommandExecution, ContinueResponse, Measurements, ParametersGatherer, | ||
PostconditionChecker, | ||
PreconditionChecker | ||
PreconditionChecker, Properties, | ||
TelemetryData | ||
} from '@salesforce/salesforcedx-utils-vscode'; | ||
import * as vscode from 'vscode'; | ||
import { EmptyPostChecker } from '.'; | ||
import { channelService } from '../../channels'; | ||
import { notificationService, ProgressNotification } from '../../notifications'; | ||
import { sfdxCoreSettings } from '../../settings'; | ||
import { taskViewService } from '../../statuses'; | ||
import { telemetryService } from '../../telemetry'; | ||
import { workspaceUtils } from '../../util'; | ||
import { EmptyPostChecker } from './emptyPostChecker'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. organize imports. |
||
|
||
export enum CommandVersion { | ||
Beta = 'beta', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { projectPaths } from '@salesforce/salesforcedx-utils-vscode'; | ||
import * as path from 'path'; | ||
import { IsvDebugBootstrapExecutor, ISVDEBUGGER } from '../../../../src/commands/isvdebugging/bootstrapCmd'; | ||
|
||
describe('isvdebugging unit test', () => { | ||
|
||
const TOOLS_FOLDER = 'tools'; | ||
let relativeToolsFolderStub: jest.SpyInstance; | ||
|
||
let isvDebugBootstrapExecutorInst: IsvDebugBootstrapExecutor; | ||
|
||
beforeEach(() => { | ||
relativeToolsFolderStub = jest.spyOn(projectPaths, 'relativeToolsFolder').mockReturnValue(TOOLS_FOLDER); | ||
}); | ||
|
||
it('should be defined', () => { | ||
isvDebugBootstrapExecutorInst = new IsvDebugBootstrapExecutor(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this wasn't required, but when testing an instance of a class it's always good to create the instance for each test. |
||
expect(isvDebugBootstrapExecutorInst).toBeDefined(); | ||
}); | ||
|
||
it('should test readonly relativeMetdataTempPath property', () => { | ||
isvDebugBootstrapExecutorInst = new IsvDebugBootstrapExecutor(); | ||
expect(isvDebugBootstrapExecutorInst.relativeMetdataTempPath).toEqual(path.join(TOOLS_FOLDER, ISVDEBUGGER)); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,13 +28,17 @@ const getMockVSCode = () => { | |
}; | ||
public dispose = () => {}; | ||
}, | ||
TreeItem: jest.fn(), | ||
commands: jest.fn(), | ||
Disposable: jest.fn(), | ||
env: { | ||
machineId: '12345534' | ||
}, | ||
EventEmitter: EventEmitter, | ||
ExtensionMode: { Production: 1, Development: 2, Test: 3 }, | ||
languages: { | ||
createDiagnosticCollection: jest.fn() | ||
}, | ||
Uri: { | ||
parse: jest.fn(), | ||
file: jest.fn() | ||
|
@@ -63,7 +67,11 @@ const getMockVSCode = () => { | |
}; | ||
}, | ||
onDidChangeConfiguration: jest.fn(), | ||
createFileSystemWatcher: jest.fn(), | ||
createFileSystemWatcher: jest.fn().mockReturnValue({ | ||
onDidChange: jest.fn(), | ||
onDidCreate: jest.fn(), | ||
onDidDelete: jest.fn() | ||
}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new vscode mock setup to get things working for core. Note that b/c the src/context/index.ts creates an instance of WorkspaceContext on initialization |
||
workspaceFolders: [] | ||
} | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd just export the TOOLS constant on line 17 vs including constants and functions here.