mirror of
https://github.com/coredns/coredns.git
synced 2025-11-12 06:52:24 -05:00
plugin/cancel: add context cancelation plugin (#2711)
* plugin/cancel: add context cancelation plugin Per review comments on #2704, move this into a plugin that gets called. Add the most minimal plugin, tests and documenation. Signed-off-by: Miek Gieben <miek@miek.nl> * plugin/cache: add timeout option review feedback: add option to set custom timeout. Signed-off-by: Miek Gieben <miek@miek.nl> * spelling Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
29
plugin/cancel/setup_test.go
Normal file
29
plugin/cancel/setup_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package cancel
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/mholt/caddy"
|
||||
)
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
c := caddy.NewTestController("dns", `cancel`)
|
||||
if err := setup(c); err != nil {
|
||||
t.Errorf("Test 1, expected no errors, but got: %q", err)
|
||||
}
|
||||
|
||||
c = caddy.NewTestController("dns", `cancel 5s`)
|
||||
if err := setup(c); err != nil {
|
||||
t.Errorf("Test 2, expected no errors, but got: %q", err)
|
||||
}
|
||||
|
||||
c = caddy.NewTestController("dns", `cancel 5`)
|
||||
if err := setup(c); err == nil {
|
||||
t.Errorf("Test 3, expected errors, but got none")
|
||||
}
|
||||
|
||||
c = caddy.NewTestController("dns", `cancel -1s`)
|
||||
if err := setup(c); err == nil {
|
||||
t.Errorf("Test 4, expected errors, but got none")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user