expectedOutput := "daemonize no\n" + "pidfile /var/run/redis.pid\n" + "port 6379\n" + "appendonly yes\n" + "client-output-buffer-limit normal 0 0 0\n" + "save 900 1\n" + "save 300 10\n" Expect(string(input.Encode())).To(Equal(expectedOutput)) }) }) Describe("CommandAlias", func() { conf := redisconf.New( redisconf.Param{Key: "rename-command", Value: "CONFIG abc-def"}, redisconf.Param{Key: "rename-command", Value: "SAVE \"123-345\""}, redisconf.Param{Key: "rename-command", Value: "BGSAVE \"\""}, ) Context("when the command is aliased", func() { It("returns the alias", func() { Expect(conf.CommandAliases()["CONFIG"]).To(Equal("abc-def")) }) }) Context("when the command is aliased with quotes", func() { It("strips the quotes", func() { Expect(conf.CommandAliases()["SAVE"]).To(Equal("123-345")) }) })
}) }) Context("when there is one redis config in the config root", func() { var ( expectedPath = "path/to/the/redis/config" expectedInstanceID = "some-instance-id" expectedTargetPath string expectedRedisConfigs = []instance.RedisConfig{ instance.RedisConfig{ Path: expectedPath, Conf: redisconf.New( redisconf.Param{ Key: "bind", Value: "8.8.8.8", }, redisconf.Param{ Key: "port", Value: "1234", }, ), }, } ) BeforeEach(func() { redisConfigFinder.FindReturns(expectedRedisConfigs, nil) instanceIDLocator.LocateIDReturns(expectedInstanceID, nil) expectedTargetPath = buildTargetPath( expectedInstanceID, backupConfig.PlanName, backupConfig.S3Config.Path,
helpers.KillProcess(agentSession) err := os.Remove(redisConfPath) Expect(err).ToNot(HaveOccurred()) agentSession = startAgent() newConf := loadRedisConfFileWhenItExists() Expect(initialConf.Get("requirepass")).NotTo(Equal(newConf.Get("requirepass"))) }) }) Context("when there is a redis.conf already", func() { BeforeEach(func() { err := redisconf.New( redisconf.Param{Key: "daemonize", Value: "yes"}, redisconf.Param{Key: "requirepass", Value: "someotherpassword"}, redisconf.Param{Key: "shouldbedeleted", Value: "yes"}, ).Save(redisConfPath) Expect(err).ToNot(HaveOccurred()) agentSession = startAgent() }) Describe("The copied redis.conf file", func() { It("has it's original password", func() { newRedisConf, err := redisconf.Load(redisConfPath) Expect(err).ToNot(HaveOccurred()) Expect(newRedisConf.Get("requirepass")).To(Equal("someotherpassword")) }) It("resets other parameters", func() { newRedisConf, err := redisconf.Load(redisConfPath)