File: posthandler.go

package info (click to toggle)
golang-github-karlseguin-expect 1.0.1+git20160716.12.5c2eadb-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 172 kB
  • sloc: makefile: 6
file content (41 lines) | stat: -rw-r--r-- 756 bytes parent folder | download | duplicates (2)
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{}) {

}