-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #38 Added tests for captain.Pre()
Execute function now returns errors instead of handling them internally. This improves testability.
- Loading branch information
1 parent
499cefa
commit 98c7758
Showing
3 changed files
with
67 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package captain // import "github.com/harbur/captain" | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestPre(t *testing.T) { | ||
app := App{ | ||
Pre: []string{"echo test"}, | ||
} | ||
res := Pre(app) | ||
|
||
assert.Nil(t, res, "No error returned") | ||
} | ||
|
||
func TestPreFail(t *testing.T) { | ||
app := App{ | ||
Pre: []string{"nonexistingCommand"}, | ||
} | ||
res := Pre(app) | ||
assert.NotNil(t, res, "Error returned") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters