Expect(tables).To(ContainElement("receipts"))
			Expect(tables).To(ContainElement("unsubscribes"))
			Expect(tables).To(ContainElement("global_unsubscribes"))
			Expect(tables).To(ContainElement("templates"))
		})
	})

	Describe("seeding the default template", func() {
		var repo models.TemplatesRepo

		BeforeEach(func() {
			repo = models.NewTemplatesRepo()
		})

		It("has the default template pre-seeded", func() {
			_, err := repo.FindByID(connection, models.DefaultTemplateID)
			Expect(err).To(BeAssignableToTypeOf(models.RecordNotFoundError("")))

			dbMigrator.Seed(database, defaultTemplatePath)
			template, err := repo.FindByID(connection, models.DefaultTemplateID)
			Expect(err).NotTo(HaveOccurred())
			Expect(template.Name).To(Equal("Default Template"))
			Expect(template.Subject).To(Equal("CF Notification: {{.Subject}}"))
			Expect(template.HTML).To(Equal("<p>{{.Endorsement}}</p>{{.HTML}}"))
			Expect(template.Text).To(Equal("{{.Endorsement}}\n{{.Text}}"))
			Expect(template.Metadata).To(Equal("{}"))
		})

		It("can be called multiple times without panicking", func() {
			Expect(func() {
				dbMigrator.Seed(database, defaultTemplatePath)
		template = models.Template{
			ID:        "raptor_template",
			Name:      "Raptors On The Run",
			Text:      "run and hide",
			HTML:      "<h1>containment unit breached!</h1>",
			CreatedAt: createdAt,
		}

		conn.Insert(&template)
	})

	Context("#FindByID", func() {
		Context("the template is in the database", func() {
			It("returns the template when it is found", func() {
				raptorTemplate, err := repo.FindByID(conn, "raptor_template")

				Expect(err).ToNot(HaveOccurred())
				Expect(raptorTemplate.ID).To(Equal("raptor_template"))
				Expect(raptorTemplate.Name).To(Equal("Raptors On The Run"))
				Expect(raptorTemplate.Text).To(Equal("run and hide"))
				Expect(raptorTemplate.HTML).To(Equal("<h1>containment unit breached!</h1>"))
			})
		})

		Context("the template is not in the database", func() {
			It("returns a record not found error", func() {
				sillyTemplate, err := repo.FindByID(conn, "silly_template")

				Expect(sillyTemplate).To(Equal(models.Template{}))
				Expect(err).To(HaveOccurred())