-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from mcarvin8/feat/shorten-cmd
Shorten Command to Allow Non-Unit Test (NUT)
- Loading branch information
Showing
10 changed files
with
133 additions
and
24 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- main | ||
|
||
jobs: | ||
unit-tests: | ||
uses: salesforcecli/github-workflows/.github/workflows/unitTest.yml@main | ||
nuts: | ||
needs: unit-tests | ||
uses: salesforcecli/github-workflows/.github/workflows/nut.yml@main | ||
secrets: inherit | ||
strategy: | ||
matrix: | ||
os: [windows-latest] | ||
fail-fast: false | ||
with: | ||
os: ${{ matrix.os }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,15 +35,15 @@ sf plugins install [email protected] | |
|
||
The `apex-code-coverage-transformer` has 1 command: | ||
|
||
- `sf apex-code-coverage transformer transform` | ||
- `sf acc-transformer transform` | ||
|
||
This command needs to be ran somewhere inside your Salesforce DX git repository, whether in the root folder (recommended) or in a subfolder. This plugin will determine the root folder of this repository and read the `sfdx-project.json` file in the root folder. All package directories listed in the `sfdx-project.json` file will be processed when running this plugin. | ||
|
||
## `sf apex-code-coverage transformer transform` | ||
## `sf acc-transformer transform` | ||
|
||
``` | ||
USAGE | ||
$ sf apex-code-coverage transformer transform -j <value> -x <value> -c <value> [--json] | ||
$ sf acc-transformer transform -j <value> -x <value> -c <value> [--json] | ||
FLAGS | ||
-j, --coverage-json=<value> Path to the code coverage JSON file created by the Salesforce CLI deployment or test command. | ||
|
@@ -57,7 +57,7 @@ DESCRIPTION | |
This plugin will convert the code coverage JSON file created by the Salesforce CLI during Apex deployments and test runs into an XML accepted by tools like SonarQube. | ||
EXAMPLES | ||
$ sf apex-code-coverage transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy" | ||
$ sf acc-transformer transform -j "coverage.json" -x "coverage.xml" -c "deploy" | ||
``` | ||
|
||
## Hook | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
import { copyFile, writeFile, readFile, rm, mkdir } from 'node:fs/promises'; | ||
import { strictEqual } from 'node:assert'; | ||
import { resolve } from 'node:path'; | ||
|
||
import { execCmd, TestSession } from '@salesforce/cli-plugins-testkit'; | ||
import { expect } from 'chai'; | ||
|
||
describe('acc-transformer transform NUTs', () => { | ||
let session: TestSession; | ||
const baselineClassPath = resolve('test/baselines/classes/AccountProfile.cls'); | ||
const baselineTriggerPath = resolve('test/baselines/triggers/AccountTrigger.trigger'); | ||
const deployCoverageNoExts = resolve('test/deploy_coverage_no_file_exts.json'); | ||
const deployCoverageWithExts = resolve('test/deploy_coverage_with_file_exts.json'); | ||
const testCoverage = resolve('test/test_coverage.json'); | ||
const baselineXmlPath = resolve('test/coverage_baseline.xml'); | ||
const testXmlPath1 = resolve('coverage1.xml'); | ||
const testXmlPath2 = resolve('coverage2.xml'); | ||
const testXmlPath3 = resolve('coverage3.xml'); | ||
|
||
const configFile = { | ||
packageDirectories: [{ path: 'force-app', default: true }, { path: 'packaged' }], | ||
namespace: '', | ||
sfdcLoginUrl: 'https://login.salesforce.com', | ||
sourceApiVersion: '58.0', | ||
}; | ||
const configJsonString = JSON.stringify(configFile, null, 2); | ||
|
||
before(async () => { | ||
session = await TestSession.create({ devhubAuthStrategy: 'NONE' }); | ||
await writeFile('sfdx-project.json', configJsonString); | ||
await mkdir('force-app/main/default/classes', { recursive: true }); | ||
await mkdir('packaged/triggers', { recursive: true }); | ||
await copyFile(baselineClassPath, 'force-app/main/default/classes/AccountProfile.cls'); | ||
await copyFile(baselineTriggerPath, 'packaged/triggers/AccountTrigger.trigger'); | ||
}); | ||
|
||
after(async () => { | ||
await session?.clean(); | ||
await rm('sfdx-project.json'); | ||
await rm('force-app/main/default/classes/AccountProfile.cls'); | ||
await rm('packaged/triggers/AccountTrigger.trigger'); | ||
await rm('force-app', { recursive: true }); | ||
await rm('packaged', { recursive: true }); | ||
await rm(testXmlPath1); | ||
await rm(testXmlPath2); | ||
await rm(testXmlPath3); | ||
}); | ||
|
||
it('runs transform on the deploy coverage file without file extensions.', async () => { | ||
const command = `acc-transformer transform --coverage-json "${deployCoverageNoExts}" --xml "${testXmlPath1}"`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
|
||
expect(output.replace('\n', '')).to.equal(`The coverage XML has been written to ${testXmlPath1}`); | ||
}); | ||
|
||
it('runs transform on the deploy coverage file with file extensions.', async () => { | ||
const command = `acc-transformer transform --coverage-json "${deployCoverageWithExts}" --xml "${testXmlPath2}"`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
|
||
expect(output.replace('\n', '')).to.equal(`The coverage XML has been written to ${testXmlPath2}`); | ||
}); | ||
|
||
it('runs transform on the test coverage file.', async () => { | ||
const command = `acc-transformer transform --coverage-json "${testCoverage}" --xml "${testXmlPath3}"`; | ||
const output = execCmd(command, { ensureExitCode: 0 }).shellOutput.stdout; | ||
|
||
expect(output.replace('\n', '')).to.equal(`The coverage XML has been written to ${testXmlPath3}`); | ||
}); | ||
it('confirm the 2 XML files created in the previous tests are the same as the baseline.', async () => { | ||
const xmlContent1 = await readFile(testXmlPath1, 'utf-8'); | ||
const xmlContent2 = await readFile(testXmlPath2, 'utf-8'); | ||
const baselineXmlContent = await readFile(baselineXmlPath, 'utf-8'); | ||
strictEqual( | ||
xmlContent1, | ||
baselineXmlContent, | ||
`File content is different between ${testXmlPath1} and ${baselineXmlPath}` | ||
); | ||
strictEqual( | ||
xmlContent2, | ||
baselineXmlContent, | ||
`File content is different between ${testXmlPath2} and ${baselineXmlPath}` | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters