Skip to content

Commit

Permalink
Added missed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
helios-ag committed Oct 13, 2018
1 parent ad3348f commit 4d4ec6a
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion checkers/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,36 @@ 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)
Expect(err).To(HaveOccurred())
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",
Expand Down

0 comments on commit 4d4ec6a

Please sign in to comment.