generated from PenaSide/GolangTemplate
55 lines
1.9 KiB
Go
55 lines
1.9 KiB
Go
![]() |
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"},
|
||
|
})
|
||
|
|
||
|
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
||
|
Logger: logger,
|
||
|
MongoDB: t.Client.Database("test"),
|
||
|
})
|
||
|
|
||
|
services := initialize.NewServices(initialize.ServicesDeps{
|
||
|
Logger: logger,
|
||
|
Clients: clients,
|
||
|
Repositories: repositories,
|
||
|
ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "http://test:8080"},
|
||
|
})
|
||
|
|
||
|
controllers := initialize.NewControllers(initialize.ControllersDeps{
|
||
|
Logger: logger,
|
||
|
Services: services,
|
||
|
})
|
||
|
|
||
|
assert.NotNil(t, controllers)
|
||
|
assert.NotNil(t, controllers.AccountController)
|
||
|
assert.NotNil(t, controllers.CurrencyController)
|
||
|
assert.NotNil(t, controllers.CartController)
|
||
|
assert.NotNil(t, controllers.HistoryController)
|
||
|
assert.NotNil(t, controllers.WalletController)
|
||
|
})
|
||
|
})
|
||
|
}
|