Skip to content

Commit

Permalink
Fixing ignored errors from fizz exec() (#71)
Browse files Browse the repository at this point in the history
* make sure that command failures with Exec() fail their migrations

* remove unused return error
  • Loading branch information
akostibas authored and markbates committed Apr 20, 2018
1 parent 788e138 commit 3325e4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions fizz/bubbler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ func Test_Exec(t *testing.T) {
b := NewBubbler(nil)
f := fizzer{b}
bb := &bytes.Buffer{}
err := f.Exec(bb).(func(string) error)("echo hello")
r.NoError(err)
f.Exec(bb).(func(string))("echo hello")
r.Equal("hello\n", bb.String())
}
8 changes: 6 additions & 2 deletions fizz/fizz.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fizz

import (
"fmt"
"io"
"io/ioutil"
"log"
Expand All @@ -24,13 +25,16 @@ func (f fizzer) add(s string, err error) error {
}

func (f fizzer) Exec(out io.Writer) interface{} {
return func(s string) error {
return func(s string) {
args := strings.Split(s, " ")
cmd := exec.Command(args[0], args[1:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = out
cmd.Stderr = os.Stderr
return cmd.Run()
err := cmd.Run()
if err != nil {
panic(fmt.Sprintf("error executing command: %s", s))
}
}
}

Expand Down

0 comments on commit 3325e4d

Please sign in to comment.