From 52c0fca9909371bb812ca764ab1519348a647943 Mon Sep 17 00:00:00 2001 From: Yuce Tekol Date: Thu, 17 Aug 2017 09:03:11 +0300 Subject: [PATCH] added a test for the client cache --- client_it_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/client_it_test.go b/client_it_test.go index 7dad854..ea750d5 100644 --- a/client_it_test.go +++ b/client_it_test.go @@ -1018,6 +1018,24 @@ func TestStatusToNodeSlicesForIndex(t *testing.T) { } } +func TestClientCache(t *testing.T) { + // even though this function isn't really an integration test, + // it needs to access getDirectClient which is not + // available to client_test.go + client := DefaultClient() + client2, err := client.getDirectClient("foo.bar:10101") + if err != nil { + t.Fatal(err) + } + client3, err := client.getDirectClient("foo.bar:10101") + if err != nil { + t.Fatal(err) + } + if client2 != client3 { + t.Fatal("Should return the same client for the same host") + } +} + func getClient() *Client { uri, err := NewURIFromAddress(":10101") if err != nil {