Beispiel #1
0
func (m *Mother) TemplateFinder() services.TemplateFinder {
	return services.NewTemplateFinder(m.TemplatesRepo())
}
var _ = Describe("Finder", func() {
	var (
		finder        services.TemplateFinder
		templatesRepo *mocks.TemplatesRepo
		database      *mocks.Database
		conn          *mocks.Connection
	)

	Describe("#FindByID", func() {
		BeforeEach(func() {
			templatesRepo = mocks.NewTemplatesRepo()
			conn = mocks.NewConnection()
			database = mocks.NewDatabase()
			database.ConnectionCall.Returns.Connection = conn

			finder = services.NewTemplateFinder(templatesRepo)
		})

		Context("when the finder returns a template", func() {
			Context("when the template exists in the database", func() {
				BeforeEach(func() {
					templatesRepo.FindByIDCall.Returns.Template = models.Template{
						ID:      "awesome-template-id",
						Name:    "Awesome New Template",
						Subject: "Wow this is really awesome",
						Text:    "awesome new hungry raptors template",
						HTML:    "<p>hungry raptors are newly awesome template</p>",
					}
				})

				It("returns the requested template", func() {