forked from go-git/go-git
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Paulo Gomes <[email protected]>
- Loading branch information
Showing
43 changed files
with
953 additions
and
135 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
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
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
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,43 @@ | ||
package test | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
check "gopkg.in/check.v1" | ||
) | ||
|
||
// This check.Checker implementation exists because there's no implementation | ||
// in the library that compares errors using `errors.Is`. If / when the check | ||
// library fixes https://github.com/go-check/check/issues/139, this code can | ||
// likely be removed and replaced with the library implementation. | ||
// | ||
// Added in Go 1.13 [https://go.dev/blog/go1.13-errors] `errors.Is` is the | ||
// best mechanism to use to compare errors that might be wrapped in other | ||
// errors. | ||
type errorIsChecker struct { | ||
*check.CheckerInfo | ||
} | ||
|
||
var ErrorIs check.Checker = errorIsChecker{ | ||
&check.CheckerInfo{ | ||
Name: "ErrorIs", | ||
Params: []string{"obtained", "expected"}, | ||
}, | ||
} | ||
|
||
func (e errorIsChecker) Check(params []interface{}, names []string) (bool, string) { | ||
obtained, ok := params[0].(error) | ||
if !ok { | ||
return false, "obtained is not an error" | ||
} | ||
expected, ok := params[1].(error) | ||
if !ok { | ||
return false, "expected is not an error" | ||
} | ||
|
||
if !errors.Is(obtained, expected) { | ||
return false, fmt.Sprintf("obtained: %+v expected: %+v", obtained, expected) | ||
} | ||
return true, "" | ||
} |
Oops, something went wrong.