]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/mitchellh/go-testing-interface/testing_go19.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / mitchellh / go-testing-interface / testing_go19.go
CommitLineData
15c0b25d
AP
1// +build go1.9
2
3// NOTE: This is a temporary copy of testing.go for Go 1.9 with the addition
4// of "Helper" to the T interface. Go 1.9 at the time of typing is in RC
5// and is set for release shortly. We'll support this on master as the default
6// as soon as 1.9 is released.
7
8package testing
9
10import (
11 "fmt"
12 "log"
13)
14
15// T is the interface that mimics the standard library *testing.T.
16//
17// In unit tests you can just pass a *testing.T struct. At runtime, outside
18// of tests, you can pass in a RuntimeT struct from this package.
19type T interface {
20 Error(args ...interface{})
21 Errorf(format string, args ...interface{})
15c0b25d
AP
22 Fail()
23 FailNow()
24 Failed() bool
107c1cdb
ND
25 Fatal(args ...interface{})
26 Fatalf(format string, args ...interface{})
15c0b25d
AP
27 Log(args ...interface{})
28 Logf(format string, args ...interface{})
107c1cdb
ND
29 Name() string
30 Skip(args ...interface{})
31 SkipNow()
32 Skipf(format string, args ...interface{})
33 Skipped() bool
34 Helper()
15c0b25d
AP
35}
36
37// RuntimeT implements T and can be instantiated and run at runtime to
38// mimic *testing.T behavior. Unlike *testing.T, this will simply panic
39// for calls to Fatal. For calls to Error, you'll have to check the errors
40// list to determine whether to exit yourself.
41type RuntimeT struct {
107c1cdb
ND
42 skipped bool
43 failed bool
15c0b25d
AP
44}
45
46func (t *RuntimeT) Error(args ...interface{}) {
47 log.Println(fmt.Sprintln(args...))
48 t.Fail()
49}
50
51func (t *RuntimeT) Errorf(format string, args ...interface{}) {
107c1cdb 52 log.Printf(format, args...)
15c0b25d
AP
53 t.Fail()
54}
55
15c0b25d
AP
56func (t *RuntimeT) Fail() {
57 t.failed = true
58}
59
60func (t *RuntimeT) FailNow() {
61 panic("testing.T failed, see logs for output (if any)")
62}
63
64func (t *RuntimeT) Failed() bool {
65 return t.failed
66}
67
107c1cdb
ND
68func (t *RuntimeT) Fatal(args ...interface{}) {
69 log.Print(args...)
70 t.FailNow()
71}
72
73func (t *RuntimeT) Fatalf(format string, args ...interface{}) {
74 log.Printf(format, args...)
75 t.FailNow()
76}
15c0b25d
AP
77
78func (t *RuntimeT) Log(args ...interface{}) {
79 log.Println(fmt.Sprintln(args...))
80}
81
82func (t *RuntimeT) Logf(format string, args ...interface{}) {
83 log.Println(fmt.Sprintf(format, args...))
84}
107c1cdb
ND
85
86func (t *RuntimeT) Name() string {
87 return ""
88}
89
90func (t *RuntimeT) Skip(args ...interface{}) {
91 log.Print(args...)
92 t.SkipNow()
93}
94
95func (t *RuntimeT) SkipNow() {
96 t.skipped = true
97}
98
99func (t *RuntimeT) Skipf(format string, args ...interface{}) {
100 log.Printf(format, args...)
101 t.SkipNow()
102}
103
104func (t *RuntimeT) Skipped() bool {
105 return t.skipped
106}
107
108func (t *RuntimeT) Helper() {}