From 4d4ec6abc0aa20cd50f2d901d550caa6356bbe13 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Sat, 13 Oct 2018 14:27:15 +1000 Subject: [PATCH] Added missed tests --- checkers/memcached_test.go | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/checkers/memcached_test.go b/checkers/memcached_test.go index 749cdfe..d4d57e8 100644 --- a/checkers/memcached_test.go +++ b/checkers/memcached_test.go @@ -62,7 +62,7 @@ func TestValidateMemcachedConfig(t *testing.T) { t.Run("Should error if none of the check methods are enabled", func(t *testing.T) { cfg := &MemcachedConfig{ - Url: "localhost:11011", + Url: testUrl, } err := validateMemcachedConfig(cfg) @@ -70,6 +70,28 @@ func TestValidateMemcachedConfig(t *testing.T) { Expect(err.Error()).To(ContainSubstring("At minimum, either cfg.Ping, cfg.Set or cfg.Get must be set")) }) + t.Run("Should error if .Set is used but key is undefined", func(t *testing.T) { + cfg := &MemcachedConfig{ + Url: testUrl, + Set: &MemcachedSetOptions{}, + } + + err := validateMemcachedConfig(cfg) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("If cfg.Set is used, cfg.Set.Key must be set")) + }) + + t.Run("Should error if .Get is used but key is undefined", func(t *testing.T) { + cfg := &MemcachedConfig{ + Url: testUrl, + Get: &MemcachedGetOptions{}, + } + + err := validateMemcachedConfig(cfg) + Expect(err).To(HaveOccurred()) + Expect(err.Error()).To(ContainSubstring("If cfg.Get is used, cfg.Get.Key must be set")) + }) + t.Run("Should error if url has wrong format", func(t *testing.T) { cfg := &MemcachedConfig{ Url: "wrong\\localhost:6379",