mirror of
https://github.com/Luzifer/duplicity-backup.git
synced 2024-11-10 08:00:12 +00:00
30 lines
738 B
Go
30 lines
738 B
Go
package matchers
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/onsi/gomega/format"
|
|
)
|
|
|
|
type SucceedMatcher struct {
|
|
}
|
|
|
|
func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err error) {
|
|
if actual == nil {
|
|
return true, nil
|
|
}
|
|
|
|
if isError(actual) {
|
|
return false, nil
|
|
}
|
|
|
|
return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1))
|
|
}
|
|
|
|
func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) {
|
|
return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1))
|
|
}
|
|
|
|
func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) {
|
|
return "Expected failure, but got no error."
|
|
}
|