aboutsummaryrefslogtreecommitdiff
path: root/plugin/forward/persistent_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/forward/persistent_test.go')
-rw-r--r--plugin/forward/persistent_test.go26
1 files changed, 20 insertions, 6 deletions
diff --git a/plugin/forward/persistent_test.go b/plugin/forward/persistent_test.go
index 5fa491a01..f4f476afa 100644
--- a/plugin/forward/persistent_test.go
+++ b/plugin/forward/persistent_test.go
@@ -19,9 +19,13 @@ func TestPersistent(t *testing.T) {
tr := newTransport(s.Addr, nil /* no TLS */)
defer tr.Stop()
- c1, _ := tr.Dial("udp")
- c2, _ := tr.Dial("udp")
- c3, _ := tr.Dial("udp")
+ c1, cache1, _ := tr.Dial("udp")
+ c2, cache2, _ := tr.Dial("udp")
+ c3, cache3, _ := tr.Dial("udp")
+
+ if cache1 || cache2 || cache3 {
+ t.Errorf("Expected non-cached connection")
+ }
tr.Yield(c1)
tr.Yield(c2)
@@ -31,13 +35,23 @@ func TestPersistent(t *testing.T) {
t.Errorf("Expected cache size to be 3, got %d", x)
}
- tr.Dial("udp")
+ c4, cache4, _ := tr.Dial("udp")
if x := tr.Len(); x != 2 {
t.Errorf("Expected cache size to be 2, got %d", x)
}
- tr.Dial("udp")
+ c5, cache5, _ := tr.Dial("udp")
if x := tr.Len(); x != 1 {
- t.Errorf("Expected cache size to be 2, got %d", x)
+ t.Errorf("Expected cache size to be 1, got %d", x)
+ }
+
+ if cache4 == false || cache5 == false {
+ t.Errorf("Expected cached connection")
+ }
+ tr.Yield(c4)
+ tr.Yield(c5)
+
+ if x := tr.Len(); x != 3 {
+ t.Errorf("Expected cache size to be 3, got %d", x)
}
}