MCPcopy Index your code
hub / github.com/imroc/req / TestMustSendMethods

Function TestMustSendMethods

request_test.go:21–83  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestMustSendMethods(t *testing.T) {
22 c := tc()
23 testCases := []struct {
24 SendReq func(req *Request, url string) *Response
25 ExpectMethod string
26 }{
27 {
28 SendReq: func(req *Request, url string) *Response {
29 return req.MustGet(url)
30 },
31 ExpectMethod: "GET",
32 },
33 {
34 SendReq: func(req *Request, url string) *Response {
35 return req.MustPost(url)
36 },
37 ExpectMethod: "POST",
38 },
39 {
40 SendReq: func(req *Request, url string) *Response {
41 return req.MustPatch(url)
42 },
43 ExpectMethod: "PATCH",
44 },
45 {
46 SendReq: func(req *Request, url string) *Response {
47 return req.MustDelete(url)
48 },
49 ExpectMethod: "DELETE",
50 },
51 {
52 SendReq: func(req *Request, url string) *Response {
53 return req.MustOptions(url)
54 },
55 ExpectMethod: "OPTIONS",
56 },
57 {
58 SendReq: func(req *Request, url string) *Response {
59 return req.MustPut(url)
60 },
61 ExpectMethod: "PUT",
62 },
63 {
64 SendReq: func(req *Request, url string) *Response {
65 return req.MustHead(url)
66 },
67 ExpectMethod: "HEAD",
68 },
69 }
70
71 for _, tc := range testCases {
72 testMethod(t, c, func(req *Request) *Response {
73 return tc.SendReq(req, "/")
74 }, tc.ExpectMethod, false)
75 }
76
77 // test panic
78 for _, tc := range testCases {

Callers

nothing calls this directly

Calls 9

tcFunction · 0.85
testMethodFunction · 0.85
MustGetMethod · 0.80
MustPostMethod · 0.80
MustPatchMethod · 0.80
MustDeleteMethod · 0.80
MustOptionsMethod · 0.80
MustPutMethod · 0.80
MustHeadMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…