diff options
author | 2018-10-27 17:37:09 +0300 | |
---|---|---|
committer | 2018-10-27 15:37:09 +0100 | |
commit | 7b25d180198a34b9c7bf2426a7b5dc4e8abfdf92 (patch) | |
tree | b6182ce75589ee296a1a367514e0de58fbd9f17a /plugin/errors/setup_test.go | |
parent | b0a89452ef863b3995cae7b8a367e0648bc00b5e (diff) | |
download | coredns-7b25d180198a34b9c7bf2426a7b5dc4e8abfdf92.tar.gz coredns-7b25d180198a34b9c7bf2426a7b5dc4e8abfdf92.tar.zst coredns-7b25d180198a34b9c7bf2426a7b5dc4e8abfdf92.zip |
plugin/errors: 'consolidate' option (#2192)
- see more details at https://github.com/infobloxopen/coredns-plugin-errors/pull/3
Diffstat (limited to 'plugin/errors/setup_test.go')
-rw-r--r-- | plugin/errors/setup_test.go | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/plugin/errors/setup_test.go b/plugin/errors/setup_test.go index 3cfd7c03c..3305f6823 100644 --- a/plugin/errors/setup_test.go +++ b/plugin/errors/setup_test.go @@ -10,24 +10,60 @@ func TestErrorsParse(t *testing.T) { tests := []struct { inputErrorsRules string shouldErr bool + optCount int }{ - {`errors`, false}, - {`errors stdout`, false}, - {`errors errors.txt`, true}, - {`errors visible`, true}, - {`errors { log visible }`, true}, + {`errors`, false, 0}, + {`errors stdout`, false, 0}, + {`errors errors.txt`, true, 0}, + {`errors visible`, true, 0}, + {`errors { log visible }`, true, 0}, {`errors - errors `, true}, - {`errors a b`, true}, + errors `, true, 0}, + {`errors a b`, true, 0}, + + {`errors { + consolidate + }`, true, 0}, + {`errors { + consolidate 1m + }`, true, 0}, + {`errors { + consolidate 1m .* extra + }`, true, 0}, + {`errors { + consolidate abc .* + }`, true, 0}, + {`errors { + consolidate 1 .* + }`, true, 0}, + {`errors { + consolidate 1m ()) + }`, true, 0}, + {`errors { + consolidate 1m ^exact$ + }`, false, 1}, + {`errors { + consolidate 1m error + }`, false, 1}, + {`errors { + consolidate 1m "format error" + }`, false, 1}, + {`errors { + consolidate 1m error1 + consolidate 5s error2 + }`, false, 2}, } for i, test := range tests { c := caddy.NewTestController("dns", test.inputErrorsRules) - _, err := errorsParse(c) + h, err := errorsParse(c) if err == nil && test.shouldErr { t.Errorf("Test %d didn't error, but it should have", i) } else if err != nil && !test.shouldErr { t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) + } else if h != nil && len(h.patterns) != test.optCount { + t.Errorf("Test %d: pattern count mismatch, expected %d, got %d", + i, test.optCount, len(h.patterns)) } } } |