Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonBaeumer committed Feb 25, 2019
1 parent 700c256 commit afa4722
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
5 changes: 5 additions & 0 deletions commander.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@ tests:
exit-code: 3
it should display help:
command: ./commander
exit-code: 0
it should execute tests:
command: ./commander test ./examples/commander.yaml
stdout: >-
✓ it should fail
exit-code: 0
8 changes: 4 additions & 4 deletions examples/commander.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tests:
"it should print hello world":
command: "echo hello world"
stdout: hello world
exit-code: 0
it should fail:
command: /bin/bash invalid
stderr: "/bin/bash: invalid: No such file or directory"
exit-code: 127
11 changes: 2 additions & 9 deletions pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,14 @@ func runTest(test commander.TestCase, results chan<- commander.TestCase) {
}

func compile(command string) *Command {
parts := strings.Split(command, " ")
executable := parts[0]

splitArgs := append(parts[:0], parts[1:]...)
args := strings.Join(splitArgs, " ")

return &Command{
cmd: executable,
args: args,
cmd: command,
}
}

// Execute executes a command on the system
func (c *Command) Execute() error {
cmd := exec.Command(c.cmd, c.args)
cmd := exec.Command("sh", "-c", c.cmd)
env := os.Environ()
cmd.Env = env

Expand Down

0 comments on commit afa4722

Please sign in to comment.