1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
package expect
import (
"fmt"
"strings"
)
var (
SuccessHandler = &SuccessPostHandler{}
)
type PostHandler interface {
Message(format string, args ...interface{})
}
type FailurePostHandler struct {
expected interface{}
actual interface{}
}
func NewFailureHandler(expected, actual interface{}) PostHandler {
return &FailurePostHandler{expected, actual}
}
func (h *FailurePostHandler) Message(format string, args ...interface{}) {
if args == nil {
s := fmt.Sprintf(format, h.expected, h.actual)
if strings.Contains(s, "%!(EXTRA") == false {
runner.ErrorMessage(s)
return
}
}
runner.ErrorMessage(format, args...)
}
type SuccessPostHandler struct {
}
func (h *SuccessPostHandler) Message(format string, args ...interface{}) {
}
|