aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/setup_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/cache/setup_test.go')
-rw-r--r--plugin/cache/setup_test.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/plugin/cache/setup_test.go b/plugin/cache/setup_test.go
index 5d8b9653c..46ac5bd9e 100644
--- a/plugin/cache/setup_test.go
+++ b/plugin/cache/setup_test.go
@@ -231,3 +231,32 @@ func TestDisable(t *testing.T) {
}
}
}
+
+func TestKeepttl(t *testing.T) {
+ tests := []struct {
+ input string
+ shouldErr bool
+ }{
+ // positive
+ {"keepttl", false},
+ // negative
+ {"keepttl arg1", true},
+ }
+ for i, test := range tests {
+ c := caddy.NewTestController("dns", fmt.Sprintf("cache {\n%s\n}", test.input))
+ ca, err := cacheParse(c)
+ if test.shouldErr && err == nil {
+ t.Errorf("Test %v: Expected error but found nil", i)
+ continue
+ } else if !test.shouldErr && err != nil {
+ t.Errorf("Test %v: Expected no error but found error: %v", i, err)
+ continue
+ }
+ if test.shouldErr {
+ continue
+ }
+ if !ca.keepttl {
+ t.Errorf("Test %v: Expected keepttl enabled but disabled", i)
+ }
+ }
+}