2023-06-22 09:36:43 +00:00
|
|
|
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"},
|
2023-11-05 13:58:41 +00:00
|
|
|
VerificationURL: &models.VerificationMicroserviceURL{Verification: ""},
|
|
|
|
TemplategenURL: &models.TemplategenMicroserviceURL{Templategen: ""},
|
2023-06-22 09:36:43 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
|
|
|
Logger: logger,
|
|
|
|
MongoDB: t.Client.Database("test"),
|
|
|
|
})
|
|
|
|
|
2024-07-12 09:37:56 +00:00
|
|
|
controllers := initialize.NewHttpControllers(initialize.HttpControllersDeps{
|
2023-07-07 01:57:06 +00:00
|
|
|
Logger: logger,
|
2024-07-12 09:37:56 +00:00
|
|
|
Repositories: repositories,
|
|
|
|
Clients: clients,
|
2023-06-22 09:36:43 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
assert.NotNil(t, controllers)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|