func (m *Mother) TemplateServiceObjects() (services.TemplateCreator, services.TemplateFinder, services.TemplateUpdater, services.TemplateDeleter, services.TemplateLister, services.TemplateAssigner, services.TemplateAssociationLister) { clientsRepo, kindsRepo := m.Repos() templatesRepo := m.TemplatesRepo() return services.NewTemplateCreator(templatesRepo), m.TemplateFinder(), services.NewTemplateUpdater(templatesRepo), services.NewTemplateDeleter(templatesRepo), services.NewTemplateLister(templatesRepo), services.NewTemplateAssigner(clientsRepo, kindsRepo, templatesRepo), services.NewTemplateAssociationLister(clientsRepo, kindsRepo, templatesRepo) }
database *mocks.Database conn *mocks.Connection ) BeforeEach(func() { conn = mocks.NewConnection() database = mocks.NewDatabase() database.ConnectionCall.Returns.Connection = conn templatesRepo = mocks.NewTemplatesRepo() _, err := templatesRepo.Create(conn, models.Template{ ID: "templateID", }) Expect(err).NotTo(HaveOccurred()) deleter = services.NewTemplateDeleter(templatesRepo) }) Describe("#Delete", func() { It("calls destroy on its repo", func() { err := deleter.Delete(database, "templateID") Expect(err).NotTo(HaveOccurred()) Expect(templatesRepo.DestroyCall.Receives.Connection).To(Equal(conn)) Expect(templatesRepo.DestroyCall.Receives.TemplateID).To(Equal("templateID")) }) It("returns an error if repo destroy returns an error", func() { templatesRepo.DestroyCall.Returns.Error = errors.New("Boom!!") err := deleter.Delete(database, "templateID")