-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Must/Should error checks for fixtures
Signed-off-by: Marek Aufart <[email protected]>
- Loading branch information
Showing
4 changed files
with
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
package client | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
// | ||
// Check error and if present, fail the test case. | ||
// Examples usage: client.Should(t, task.Create(&r)) | ||
func Should(t *testing.T, err error) { | ||
if err != nil { | ||
t.Errorf(err.Error()) | ||
} | ||
} | ||
|
||
// | ||
// Check error and if present, fail and stop the test suite. | ||
// Examples usage: client.Must(t, task.Create(&r)) | ||
func Must(t *testing.T, err error) { | ||
if err != nil { | ||
t.Fatalf(err.Error()) | ||
} | ||
} | ||
|
||
// | ||
// Simple equality check working for flat types (no nested types passed by reference). | ||
func FlatEqual(got, expected interface{}) bool { | ||
return fmt.Sprintf("%v", got) == fmt.Sprintf("%v", expected) | ||
} |
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
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