diff options
Diffstat (limited to 'middleware/log/setup_test.go')
-rw-r--r-- | middleware/log/setup_test.go | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/middleware/log/setup_test.go b/middleware/log/setup_test.go index 243d6aeb6..8ae4fa03b 100644 --- a/middleware/log/setup_test.go +++ b/middleware/log/setup_test.go @@ -3,6 +3,8 @@ package log import ( "testing" + "github.com/miekg/coredns/middleware/pkg/response" + "github.com/mholt/caddy" ) @@ -43,7 +45,7 @@ func TestLogParse(t *testing.T) { Format: CombinedLogFormat, }}}, {`log example.org. log.txt - log example.net accesslog.txt {combined}`, false, []Rule{{ + log example.net accesslog.txt {combined}`, false, []Rule{{ NameScope: "example.org.", OutputFile: "log.txt", Format: DefaultLogFormat, @@ -53,7 +55,7 @@ func TestLogParse(t *testing.T) { Format: CombinedLogFormat, }}}, {`log example.org stdout {host} - log example.org log.txt {when}`, false, []Rule{{ + log example.org log.txt {when}`, false, []Rule{{ NameScope: "example.org.", OutputFile: "stdout", Format: "{host}", @@ -62,6 +64,31 @@ func TestLogParse(t *testing.T) { OutputFile: "log.txt", Format: "{when}", }}}, + + {`log example.org log.txt { + class all + }`, false, []Rule{{ + NameScope: "example.org.", + OutputFile: "log.txt", + Format: CommonLogFormat, + Class: response.All, + }}}, + {`log example.org log.txt { + class denial + }`, false, []Rule{{ + NameScope: "example.org.", + OutputFile: "log.txt", + Format: CommonLogFormat, + Class: response.Denial, + }}}, + {`log { + class denial + }`, false, []Rule{{ + NameScope: ".", + OutputFile: DefaultLogFilename, + Format: CommonLogFormat, + Class: response.Denial, + }}}, } for i, test := range tests { c := caddy.NewTestController("dns", test.inputLogRules) @@ -92,6 +119,11 @@ func TestLogParse(t *testing.T) { t.Errorf("Test %d expected %dth LogRule Format to be %s , but got %s", i, j, test.expectedLogRules[j].Format, actualLogRule.Format) } + + if actualLogRule.Class != test.expectedLogRules[j].Class { + t.Errorf("Test %d expected %dth LogRule Class to be %s , but got %s", + i, j, test.expectedLogRules[j].Class, actualLogRule.Class) + } } } |