diff options
author | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
---|---|---|
committer | Alex Pilon <apilon@hashicorp.com> | 2019-02-22 18:24:37 -0500 |
commit | 15c0b25d011f37e7c20aeca9eaf461f78285b8d9 (patch) | |
tree | 255c250a5c9d4801c74092d33b7337d8c14438ff /vendor/github.com/mitchellh/go-testing-interface/testing_go19.go | |
parent | 07971ca38143c5faf951d152fba370ddcbe26ad5 (diff) | |
download | terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.gz terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.tar.zst terraform-provider-statuscake-15c0b25d011f37e7c20aeca9eaf461f78285b8d9.zip |
deps: github.com/hashicorp/terraform@sdk-v0.11-with-go-modules
Updated via: go get github.com/hashicorp/terraform@sdk-v0.11-with-go-modules and go mod tidy
Diffstat (limited to 'vendor/github.com/mitchellh/go-testing-interface/testing_go19.go')
-rw-r--r-- | vendor/github.com/mitchellh/go-testing-interface/testing_go19.go | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/vendor/github.com/mitchellh/go-testing-interface/testing_go19.go b/vendor/github.com/mitchellh/go-testing-interface/testing_go19.go new file mode 100644 index 0000000..07fbcb5 --- /dev/null +++ b/vendor/github.com/mitchellh/go-testing-interface/testing_go19.go | |||
@@ -0,0 +1,80 @@ | |||
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 | |||
8 | package testing | ||
9 | |||
10 | import ( | ||
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. | ||
19 | type T interface { | ||
20 | Error(args ...interface{}) | ||
21 | Errorf(format string, args ...interface{}) | ||
22 | Fatal(args ...interface{}) | ||
23 | Fatalf(format string, args ...interface{}) | ||
24 | Fail() | ||
25 | FailNow() | ||
26 | Failed() bool | ||
27 | Helper() | ||
28 | Log(args ...interface{}) | ||
29 | Logf(format string, args ...interface{}) | ||
30 | } | ||
31 | |||
32 | // RuntimeT implements T and can be instantiated and run at runtime to | ||
33 | // mimic *testing.T behavior. Unlike *testing.T, this will simply panic | ||
34 | // for calls to Fatal. For calls to Error, you'll have to check the errors | ||
35 | // list to determine whether to exit yourself. | ||
36 | type RuntimeT struct { | ||
37 | failed bool | ||
38 | } | ||
39 | |||
40 | func (t *RuntimeT) Error(args ...interface{}) { | ||
41 | log.Println(fmt.Sprintln(args...)) | ||
42 | t.Fail() | ||
43 | } | ||
44 | |||
45 | func (t *RuntimeT) Errorf(format string, args ...interface{}) { | ||
46 | log.Println(fmt.Sprintf(format, args...)) | ||
47 | t.Fail() | ||
48 | } | ||
49 | |||
50 | func (t *RuntimeT) Fatal(args ...interface{}) { | ||
51 | log.Println(fmt.Sprintln(args...)) | ||
52 | t.FailNow() | ||
53 | } | ||
54 | |||
55 | func (t *RuntimeT) Fatalf(format string, args ...interface{}) { | ||
56 | log.Println(fmt.Sprintf(format, args...)) | ||
57 | t.FailNow() | ||
58 | } | ||
59 | |||
60 | func (t *RuntimeT) Fail() { | ||
61 | t.failed = true | ||
62 | } | ||
63 | |||
64 | func (t *RuntimeT) FailNow() { | ||
65 | panic("testing.T failed, see logs for output (if any)") | ||
66 | } | ||
67 | |||
68 | func (t *RuntimeT) Failed() bool { | ||
69 | return t.failed | ||
70 | } | ||
71 | |||
72 | func (t *RuntimeT) Helper() {} | ||
73 | |||
74 | func (t *RuntimeT) Log(args ...interface{}) { | ||
75 | log.Println(fmt.Sprintln(args...)) | ||
76 | } | ||
77 | |||
78 | func (t *RuntimeT) Logf(format string, args ...interface{}) { | ||
79 | log.Println(fmt.Sprintf(format, args...)) | ||
80 | } | ||