示例#1
0
func (m *Mother) TemplatesLoader() postal.TemplatesLoader {
	database := m.Database()
	clientsRepo, kindsRepo := m.Repos()
	templatesRepo := m.TemplatesRepo()

	v2templatesRepo := v2models.NewTemplatesRepository(uuid.NewV4)
	templatesCollection := collections.NewTemplatesCollection(v2templatesRepo)

	return postal.NewTemplatesLoader(database, clientsRepo, kindsRepo, templatesRepo, templatesCollection)
}
		conn                db.ConnectionInterface
		database            *mocks.Database
		templatesCollection *mocks.TemplatesCollection
	)

	BeforeEach(func() {
		clientsRepo = mocks.NewClientsRepository()
		kindsRepo = mocks.NewKindsRepo()
		templatesRepo = mocks.NewTemplatesRepo()

		conn = mocks.NewConnection()
		database = mocks.NewDatabase()
		database.ConnectionCall.Returns.Connection = conn

		templatesCollection = mocks.NewTemplatesCollection()
		loader = postal.NewTemplatesLoader(database, clientsRepo, kindsRepo, templatesRepo, templatesCollection)
	})

	Describe("LoadTemplates", func() {
		BeforeEach(func() {
			clientsRepo.FindCall.Returns.Client = models.Client{
				ID:         "my-client-id",
				TemplateID: models.DefaultTemplateID,
			}

			kindsRepo.FindCall.Returns.Kinds = []models.Kind{
				{
					ID:         "my-kind-id",
					ClientID:   "my-client-id",
					TemplateID: models.DefaultTemplateID,
				},