Skip to content

Commit

Permalink
feat(core): execute assert print regexp on error
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Jun 17, 2024
1 parent f5b30b6 commit b40ec29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core/lib/actions/execute/assert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export default {
}
if (!config.not) {
if (!content.test(stdout)) {
throw utils.error('NIKITA_EXECUTE_ASSERT_CONTENT_REGEX', ['the command output is not matching the content regexp,', `got ${JSON.stringify(stdout)}`, `while expecting to match ${JSON.stringify(content)}.`]);
throw utils.error('NIKITA_EXECUTE_ASSERT_CONTENT_REGEX', ['the command output is not matching the content regexp,', `got ${JSON.stringify(stdout)}`, `while expecting to match ${content.toString()}.`]);
}
} else {
if (content.test(stdout)) {
throw utils.error('NIKITA_EXECUTE_ASSERT_NOT_CONTENT_REGEX', ['the command output is unfortunately matching the content regexp,', `got ${JSON.stringify(stdout)}`, `matching ${JSON.stringify(content)}.`]);
throw utils.error('NIKITA_EXECUTE_ASSERT_NOT_CONTENT_REGEX', ['the command output is unfortunately matching the content regexp,', `got ${JSON.stringify(stdout)}`, `matching ${content.toString()}.`]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/actions/execute/assert.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe 'actions.execute.assert', ->
.should.be.rejectedWith [
'NIKITA_EXECUTE_ASSERT_CONTENT_REGEX:'
'the command output is not matching the content regexp,'
'got "toto\\nest\\r\\nau\\rbistrot\\n" while expecting to match {}.'
'got "toto\\nest\\r\\nau\\rbistrot\\n" while expecting to match /^ohno$/m.'
].join ' '

they 'option trim on command', ({ssh}) ->
Expand Down

0 comments on commit b40ec29

Please sign in to comment.