aboutsummaryrefslogtreecommitdiff
path: root/plugin/cache/setup_test.go
diff options
context:
space:
mode:
authorGravatar Arthur Outhenin-Chalandre <arthur@cri.epita.fr> 2023-01-27 17:35:24 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-27 11:35:24 -0500
commitbf7c2cf37bf35ba3a7596cb32c5a3607d896f95d (patch)
tree83a2dc9ae6ec2bd04074f42dd0d5f1962f916f68 /plugin/cache/setup_test.go
parentd3e4fc78c3b80c1768b0f95ad849b07ba9968ba5 (diff)
downloadcoredns-bf7c2cf37bf35ba3a7596cb32c5a3607d896f95d.tar.gz
coredns-bf7c2cf37bf35ba3a7596cb32c5a3607d896f95d.tar.zst
coredns-bf7c2cf37bf35ba3a7596cb32c5a3607d896f95d.zip
plugin/cache: add a new keepttl option (#5879)
adds a new option `keepttl` to the cache plugin Signed-off-by: Arthur Outhenin-Chalandre <arthur.outhenin-chalandre@proton.ch>
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)
+ }
+ }
+}