From 602824623be4ccc422a7bcced725e54a760ba55d Mon Sep 17 00:00:00 2001 From: Anatolii Mihailenco Date: Fri, 8 Jan 2016 15:03:34 +0200 Subject: [PATCH] commands.go: add section parameter to Info function. --- commands.go | 9 ++++++--- commands_test.go | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/commands.go b/commands.go index 215f414c..d6cb800d 100644 --- a/commands.go +++ b/commands.go @@ -1454,9 +1454,12 @@ func (c *commandable) FlushDb() *StatusCmd { return cmd } -func (c *commandable) Info() *StringCmd { - cmd := NewStringCmd("INFO") - cmd._clusterKeyPos = 0 +func (c *commandable) Info(section ...string) *StringCmd { + args := []interface{}{"INFO"} + if len(section) > 0 { + args = append(args, section[0]) + } + cmd := NewStringCmd(args...) c.Process(cmd) return cmd } diff --git a/commands_test.go b/commands_test.go index c592090a..f7d5502e 100644 --- a/commands_test.go +++ b/commands_test.go @@ -130,6 +130,13 @@ var _ = Describe("Commands", func() { Expect(info.Val()).NotTo(Equal("")) }) + It("should Info cpu", func() { + info := client.Info("cpu") + Expect(info.Err()).NotTo(HaveOccurred()) + Expect(info.Val()).NotTo(Equal("")) + Expect(info.Val()).To(ContainSubstring(`used_cpu_sys`)) + }) + It("should LastSave", func() { lastSave := client.LastSave() Expect(lastSave.Err()).NotTo(HaveOccurred())