MCPcopy
hub / github.com/caddyserver/caddy / TestResponseMatcher

Function TestResponseMatcher

modules/caddyhttp/responsematchers_test.go:22–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

20)
21
22func TestResponseMatcher(t *testing.T) {
23 for i, tc := range []struct {
24 require ResponseMatcher
25 status int
26 hdr http.Header // make sure these are canonical cased (std lib will do that in a real request)
27 expect bool
28 }{
29 {
30 require: ResponseMatcher{},
31 status: 200,
32 expect: true,
33 },
34 {
35 require: ResponseMatcher{
36 StatusCode: []int{200},
37 },
38 status: 200,
39 expect: true,
40 },
41 {
42 require: ResponseMatcher{
43 StatusCode: []int{2},
44 },
45 status: 200,
46 expect: true,
47 },
48 {
49 require: ResponseMatcher{
50 StatusCode: []int{201},
51 },
52 status: 200,
53 expect: false,
54 },
55 {
56 require: ResponseMatcher{
57 StatusCode: []int{2},
58 },
59 status: 301,
60 expect: false,
61 },
62 {
63 require: ResponseMatcher{
64 StatusCode: []int{3},
65 },
66 status: 301,
67 expect: true,
68 },
69 {
70 require: ResponseMatcher{
71 StatusCode: []int{3},
72 },
73 status: 399,
74 expect: true,
75 },
76 {
77 require: ResponseMatcher{
78 StatusCode: []int{3},
79 },

Callers

nothing calls this directly

Calls 1

MatchMethod · 0.65

Tested by

no test coverage detected