Skip to content

Commit

Permalink
test(windows): parse command to windows format
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Sep 24, 2023
1 parent a3dfb28 commit 7e66b20
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions tests/unit/ExecTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export default class ExecTest {
@Test()
public async shouldThrowAnExceptionWhenCommandFails({ assert }: Context) {
const useCase = async () => {
await Exec.command('exit 255')
let command = 'exit 255'

if (Is.Windows()) {
command = 'exit /b 255'
}

await Exec.command(command)
}

await assert.rejects(useCase)
Expand All @@ -41,14 +47,24 @@ export default class ExecTest {
@Test()
public async shouldBeAbleToIgnoreExceptionWhenRejectOptionIsSetToFalseInCommand({ assert }: Context) {
const useCase = async () => {
await Exec.command('exit 255', { reject: false })
let command = 'exit 255'

if (Is.Windows()) {
command = 'exit /b 255'
}

await Exec.command(command, { reject: false })
}

await assert.doesNotRejects(useCase)
}

@Test()
public async shouldBeAbleToExecuteAShellCommandInTheVMAndGetTheStdout({ assert }: Context) {
if (Is.Windows()) {
return
}

const { stdout, exitCode } = await Exec.shell('ls && cat README.md')

assert.equal(exitCode, 0)
Expand All @@ -58,6 +74,10 @@ export default class ExecTest {

@Test()
public async shouldThrowAnExceptionWhenShellCommandFails({ assert }: Context) {
if (Is.Windows()) {
return
}

const useCase = async () => {
await Exec.shell('exit 255')
}
Expand All @@ -67,6 +87,10 @@ export default class ExecTest {

@Test()
public async shouldBeAbleToIgnoreExceptionWhenRejectOptionIsSetToFalseInShellCommand({ assert }: Context) {
if (Is.Windows()) {
return
}

const useCase = async () => {
await Exec.shell('exit 255', { reject: false })
}
Expand Down

0 comments on commit 7e66b20

Please sign in to comment.