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

Function TestParseOneAndImport

caddyconfig/caddyfile/parse_test.go:129–372  ·  caddyconfig/caddyfile/parse_test.go::TestParseOneAndImport
(t *testing.T)

Source from the content-addressed store, hash-verified

127}
128
129func TestParseOneAndImport(t *testing.T) {
130 testParseOne := func(input string) (ServerBlock, error) {
131 p := testParser(input)
132 p.Next() // parseOne doesn't call Next() to start, so we must
133 err := p.parseOne()
134 return p.block, err
135 }
136
137 for i, test := range []struct {
138 input string
139 shouldErr bool
140 keys []string
141 numTokens []int // number of tokens to expect in each segment
142 }{
143 {`localhost`, false, []string{
144 "localhost",
145 }, []int{}},
146
147 {`localhost
148 dir1`, false, []string{
149 "localhost",
150 }, []int{1}},
151
152 {
153 `localhost:1234
154 dir1 foo bar`, false, []string{
155 "localhost:1234",
156 }, []int{3},
157 },
158
159 {`localhost {
160 dir1
161 }`, false, []string{
162 "localhost",
163 }, []int{1}},
164
165 {`localhost:1234 {
166 dir1 foo bar
167 dir2
168 }`, false, []string{
169 "localhost:1234",
170 }, []int{3, 1}},
171
172 {`http://localhost https://localhost
173 dir1 foo bar`, false, []string{
174 "http://localhost",
175 "https://localhost",
176 }, []int{3}},
177
178 {`http://localhost https://localhost {
179 dir1 foo bar
180 }`, false, []string{
181 "http://localhost",
182 "https://localhost",
183 }, []int{3}},
184
185 {`http://localhost, https://localhost {
186 dir1 foo bar

Callers

nothing calls this directly

Calls 4

testParserFunction · 0.85
parseOneMethod · 0.80
GetKeysTextMethod · 0.80
NextMethod · 0.65

Tested by

no test coverage detected