forked from beme/abide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_test.go
49 lines (42 loc) · 930 Bytes
/
example_test.go
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
42
43
44
45
46
47
48
49
package abide_test
import (
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/beme/abide"
)
var (
handler = func(*httptest.ResponseRecorder, *http.Request) {}
t = &testing.T{}
)
func ExampleAssertHTTPResponse() {
req := httptest.NewRequest(http.MethodGet, "http://example.com", nil)
w := httptest.NewRecorder()
handler(w, req)
res := w.Result()
abide.AssertHTTPResponse(t, "http response", res)
}
func ExampleAssertReader() {
file, _ := os.Open("/path/to/file")
abide.AssertReader(t, "io reader", file)
}
func ExampleString() {
myString := "this is a string I want to snapshot"
abide.Assert(t, "assertable string", abide.String(myString))
}
func ExampleInterface() {
type MyStruct struct {
Field1 string
Field2 int64
Field3 bool
field4 string
}
myStruct := MyStruct{
"String1",
1234567,
true,
"string4",
}
abide.Assert(t, "assertable struct", abide.Interface(myStruct))
}