-
Notifications
You must be signed in to change notification settings - Fork 2
/
get_test.go
61 lines (53 loc) · 990 Bytes
/
get_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
50
51
52
53
54
55
56
57
58
59
60
61
package nethttp
import (
"testing"
)
func TestGet(t *testing.T) {
tests := []testCase{
{
name: "check get builtin",
input: `
print(http.get)
`,
output: `<built-in function http.get>`,
},
{
name: "get response.status",
input: `
print(http.get("https://httpbin.org/get").status)
`,
output: `200 OK`,
},
{
name: "get response.code",
input: `
print(http.get("https://httpbin.org/get").code)
`,
output: `200`,
},
{
name: "get response.error",
input: `
print(http.get("https://httpbin.org/get").error)
`,
output: ``,
},
{
name: "get 404",
input: `
print(http.get("https://httpbin.org/idontexist").status)
`,
output: `404 NOT FOUND`, // depends on server for response message
},
{
name: "get error",
input: `
print(http.get("ssh://httpbin.org/idontexist").error)
`,
output: `Get ssh://httpbin.org/idontexist: unsupported protocol scheme "ssh"`,
},
}
for i, tc := range tests {
runTestCase(t, i, &tc)
}
}