Skip to content

Commit

Permalink
fix: how --json parameter output is handled (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
scolladon authored May 22, 2023
1 parent 27de245 commit 3484e31
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Thanks for sending a pull request! Please make sure to have a look to the contri
closes #

- [ ] Jest tests added to cover the fix.
- [ ] NUT tests added to cover the fix.
- [ ] E2E tests added to cover the fix.

# Any particular element that can be tested locally
Expand Down
32 changes: 32 additions & 0 deletions __tests__/functional/delta.nut.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,36 @@ describe('sgd:source:delta NUTS', () => {
}).shellOutput
expect(result).to.include('sgd:source:delta')
})

it('detects not existing output folder', () => {
const result = execCmd('sgd:source:delta --from "HEAD"', {
ensureExitCode: 1,
}).shellOutput
expect(result).to.include('folder does not exist')
expect(result).to.include('"success": false')
})

it('detects not existing output folder with json outputs', () => {
const result = execCmd('sgd:source:delta --from "HEAD" --json', {
ensureExitCode: 1,
}).shellOutput
expect(result).to.include('folder does not exist')
expect(result).to.include('"success": false')
})

it('outputs json', () => {
const result = execCmd('sgd:source:delta --from "HEAD" -o reports', {
ensureExitCode: 0,
}).shellOutput
expect(result).to.include('"error": null')
expect(result).to.include('"success": true')
})

it('outputs json with `--json`', () => {
const result = execCmd('sgd:source:delta --from "HEAD" -o reports --json', {
ensureExitCode: 0,
}).shellOutput
expect(result).to.include('"error": null')
expect(result).to.include('"success": true')
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"@swc/core": "^1.3.58",
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^20.1.5",
"@types/node": "^20.1.7",
"@typescript-eslint/eslint-plugin": "^5.59.6",
"@typescript-eslint/parser": "^5.59.6",
"chai": "^4.3.7",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/sgd/source/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,6 @@ export default class SourceDeltaGenerate extends SfdxCommand {
process.exitCode = 1
}
this.ux.log(JSON.stringify(output, null, 2))
return null
return output
}
}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2234,10 +2234,10 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^20.1.5":
version: 20.1.5
resolution: "@types/node@npm:20.1.5"
checksum: 0d073ed7b9cc51e2354dcf3a8ccca84d08c7d513fa8fac9462cabc164435b30f2ad296e9f2f911e6ce72da837b704f1075379be84a93bb24f76d328a2d9e8561
"@types/node@npm:^20.1.7":
version: 20.1.7
resolution: "@types/node@npm:20.1.7"
checksum: b722794290d22db1741e739c256876ca774b76ea2d647d9ec9d52c49b1b01049cc6f6332499a01ac81d641e8d078b33e4c5c59e409db80390ac6b8d7ef0c08a7
languageName: node
linkType: hard

Expand Down Expand Up @@ -8717,7 +8717,7 @@ __metadata:
"@swc/core": ^1.3.58
"@types/chai": ^4.3.5
"@types/mocha": ^10.0.1
"@types/node": ^20.1.5
"@types/node": ^20.1.7
"@typescript-eslint/eslint-plugin": ^5.59.6
"@typescript-eslint/parser": ^5.59.6
chai: ^4.3.7
Expand Down

0 comments on commit 3484e31

Please sign in to comment.