-
Notifications
You must be signed in to change notification settings - Fork 143
feat: added RunRelevantTests test-level @W-20152151@ #1644
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
| "@salesforce/kit": "^3.2.4", | ||
| "@salesforce/ts-types": "^2.0.12", | ||
| "@salesforce/types": "^1.5.0", | ||
| "@types/semver": "^7.7.1", | ||
| "fast-levenshtein": "^3.0.0", | ||
| "fast-xml-parser": "^4.5.3", | ||
| "got": "^11.8.6", | ||
|
|
@@ -38,6 +39,7 @@ | |
| "mime": "2.6.0", | ||
| "minimatch": "^9.0.5", | ||
| "proxy-agent": "^6.4.0", | ||
| "semver": "^7.7.3", | ||
|
||
| "yaml": "^2.8.1" | ||
| }, | ||
| "devDependencies": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import { format } from 'node:util'; | |
| import { isString } from '@salesforce/ts-types'; | ||
| import JSZip from 'jszip'; | ||
| import fs from 'graceful-fs'; | ||
| import semver from 'semver'; | ||
| import { Lifecycle } from '@salesforce/core/lifecycle'; | ||
| import { Messages } from '@salesforce/core/messages'; | ||
| import { SfError } from '@salesforce/core/sfError'; | ||
|
|
@@ -116,6 +117,7 @@ export class MetadataApiDeploy extends MetadataTransfer< | |
| public constructor(options: MetadataApiDeployOptions) { | ||
| super(options); | ||
| options.apiOptions = { ...MetadataApiDeploy.DEFAULT_OPTIONS.apiOptions, ...options.apiOptions }; | ||
| validateOptions(options); | ||
|
Contributor
Author
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. Ordinarily, I dislike putting errors in a constructor, but doing it here lets us fail faster at the immediate point of invalidity instead of waiting to do it somewhere else. |
||
| this.options = Object.assign({}, options); | ||
| this.isRestDeploy = !!options.apiOptions?.rest; | ||
| this.registry = options.registry ?? new RegistryAccess(); | ||
|
|
@@ -524,6 +526,17 @@ const buildFileResponsesFromComponentSet = | |
| } | ||
| return fileResponses; | ||
| }; | ||
|
|
||
| const validateOptions = (options: MetadataApiDeployOptions): void => { | ||
|
Contributor
Author
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. Tried to keep this method open-ended so we can expand on it in the future as needed.
Contributor
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. Either are fine. Consistency at least within the file (and ideally the library) should be preferred. |
||
| const runningRelevantTestsOnly = options.apiOptions?.testLevel === 'RunRelevantTests'; | ||
| const beforeApiV66 = options.apiVersion && semver.lt(semver.coerce(options.apiVersion)!, '66.0.0'); | ||
| if (runningRelevantTestsOnly && beforeApiV66) { | ||
| throw new SfError( | ||
| messages.getMessage('error_invalid_test_level', ['RunRelevantTests', '66.0']), | ||
| 'InvalidTestLevelSelection' | ||
| ); | ||
| } | ||
| }; | ||
| /** | ||
| * register a listener to `scopedPreDeploy` | ||
| */ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1256,6 +1256,27 @@ describe('MetadataApiDeploy', () => { | |
| expect(mdOpts.zipPath).to.equal('foo/myZip.zip'); | ||
| }); | ||
|
|
||
| it('should disallow "RunRelevantTests" for API versions <66.0', () => { | ||
| const constructorError = { | ||
| name: 'InvalidTestLevelSelection', | ||
| message: messages.getMessage('error_invalid_test_level', ['RunRelevantTests', '66.0']), | ||
| }; | ||
| try { | ||
| new MetadataApiDeploy({ | ||
| usernameOrConnection: 'testing', | ||
| apiOptions: { | ||
| testLevel: 'RunRelevantTests', | ||
| }, | ||
| apiVersion: '8.0', // Tricksy case here: 8.0 is alphabetically after "66.0" but semantically after it. | ||
|
||
| }); | ||
| assert.fail('Should have thrown an error'); | ||
| } catch (e) { | ||
| assert(e instanceof Error); | ||
| expect(e.name).to.equal(constructorError.name); | ||
| expect(e.message).to.equal(constructorError.message); | ||
| } | ||
| }); | ||
|
|
||
| it('should allow mdapi path', () => { | ||
| const mdApiDeploy = new MetadataApiDeploy({ | ||
| usernameOrConnection: 'testing', | ||
|
|
||
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.
I imagine this message needs to go through some kind of review from a tech writer?
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.
@jshackell-sfdc - can you please review this?