securityGroupRepo.ReadReturns(models.SecurityGroup{}, errors.New("pbbbbbbbbbbt")) }) It("fails and tells the user", func() { runCommand("-f", "whoops") Expect(ui.Outputs()).To(ContainSubstrings([]string{"FAILED"})) }) }) Context("when a group with that name does not exist", func() { BeforeEach(func() { securityGroupRepo.ReadReturns(models.SecurityGroup{}, errors.NewModelNotFoundError("Security group", "uh uh uh -- you didn't sahy the magick word")) }) It("fails and tells the user", func() { runCommand("-f", "whoop") Expect(ui.WarnOutputs).To(ContainSubstrings([]string{"whoop", "does not exist"})) }) }) It("fails and warns the user if deleting fails", func() { securityGroupRepo.DeleteReturns(errors.New("raspberry")) runCommand("-f", "whoops") Expect(ui.Outputs()).To(ContainSubstrings([]string{"FAILED"})) }) }) })