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

Function TestGlobalLogOptionSyntax

caddyconfig/httpcaddyfile/options_test.go:14–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestGlobalLogOptionSyntax(t *testing.T) {
15 for i, tc := range []struct {
16 input string
17 output string
18 expectError bool
19 }{
20 // NOTE: Additional test cases of successful Caddyfile parsing
21 // are present in: caddytest/integration/caddyfile_adapt/
22 {
23 input: `{
24 log default
25 }
26 `,
27 output: `{}`,
28 expectError: false,
29 },
30 {
31 input: `{
32 log example {
33 output file foo.log
34 }
35 log example {
36 format json
37 }
38 }
39 `,
40 expectError: true,
41 },
42 {
43 input: `{
44 log example /foo {
45 output file foo.log
46 }
47 }
48 `,
49 expectError: true,
50 },
51 } {
52
53 adapter := caddyfile.Adapter{
54 ServerType: ServerType{},
55 }
56
57 out, _, err := adapter.Adapt([]byte(tc.input), nil)
58
59 if err != nil != tc.expectError {
60 t.Errorf("Test %d error expectation failed Expected: %v, got %v", i, tc.expectError, err)
61 continue
62 }
63
64 if string(out) != tc.output {
65 t.Errorf("Test %d error output mismatch Expected: %s, got %s", i, tc.output, out)
66 }
67 }
68}
69
70func TestGlobalResolversOption(t *testing.T) {
71 tests := []struct {

Callers

nothing calls this directly

Calls 1

AdaptMethod · 0.95

Tested by

no test coverage detected