localInstanceCreator = &redis.LocalInstanceCreator{ FindFreePort: fakeFreePortFinder, ProcessController: fakeProcessController, LocalInstanceRepository: fakeLocalRepository, RedisConfiguration: brokerconfig.ServiceConfiguration{ ServiceInstanceLimit: 1, }, } }) Describe("Create", func() { Context("when retrieving the number of instances fails", func() { BeforeEach(func() { localInstanceCreator.LocalInstanceRepository = &fakes.FakeLocalRepository{ DeletedInstanceIds: []string{}, CreatedInstances: []*redis.Instance{}, Instances: []*redis.Instance{}, InstanceCountErr: errors.New("could not retrieve instance count"), } }) It("should return an error if unable to retrieve instance count", func() { err := localInstanceCreator.Create(instanceID) Ω(err).To(HaveOccurred()) }) }) Context("when the service instance limit has not been met", func() { BeforeEach(func() { freePortsFound = 0 })