package initialize_test

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"go.mongodb.org/mongo-driver/mongo/integration/mtest"
	"go.uber.org/zap"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/initialize"
	"penahub.gitlab.yandexcloud.net/pena-services/customer/internal/models"
)

func TestNewControllers(t *testing.T) {
	mt := mtest.New(t, mtest.NewOptions().ClientType(mtest.Mock))

	mt.Run("Контроллеры должны успешно инициализироваться", func(t *mtest.T) {
		logger := zap.New(zap.L().Core())

		assert.NotPanics(t, func() {
			clients := initialize.NewClients(initialize.ClientsDeps{
				Logger:                       logger,
				AuthURL:                      &models.AuthMicroserviceURL{},
				HubadminURL:                  &models.HubadminMicroserviceURL{},
				CurrencyURL:                  &models.CurrencyMicroserviceURL{},
				DiscountServiceConfiguration: &models.DiscountMicroserviceConfiguration{HostGRPC: "host"},
				PaymentServiceConfiguration:  &models.PaymentMicroserviceConfiguration{HostGRPC: "host"},
				VerificationURL:              &models.VerificationMicroserviceURL{Verification: ""},
				TemplategenURL:               &models.TemplategenMicroserviceURL{Templategen: ""},
			})

			repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
				Logger:  logger,
				MongoDB: t.Client.Database("test"),
			})

			controllers := initialize.NewHttpControllers(initialize.HttpControllersDeps{
				Logger:       logger,
				Repositories: repositories,
				Clients:      clients,
			})

			assert.NotNil(t, controllers)
		})
	})
}
