forked from gavv/httpexpect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathe2e_fs_test.go
More file actions
46 lines (38 loc) · 773 Bytes
/
e2e_fs_test.go
File metadata and controls
46 lines (38 loc) · 773 Bytes
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
package httpexpect
import (
"io/ioutil"
"net/http"
"os"
"path"
"testing"
"github.com/valyala/fasthttp"
)
func TestE2EFsFastBinder(t *testing.T) {
tempdir, err := ioutil.TempDir("", "httpexpect")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(tempdir)
if err := ioutil.WriteFile(
path.Join(tempdir, "hello"), []byte("hello, world!"), 0666); err != nil {
t.Fatal(err)
}
fs := &fasthttp.FS{
Root: tempdir,
}
handler := fs.NewRequestHandler()
e := WithConfig(Config{
Client: &http.Client{
Transport: NewFastBinder(handler),
Jar: NewJar(),
},
Reporter: NewAssertReporter(t),
Printers: []Printer{
NewDebugPrinter(t, true),
},
})
e.GET("/hello").
Expect().
Status(http.StatusOK).
Text().Equal("hello, world!")
}