generated from PenaSide/GolangTemplate
62 lines
2.2 KiB
Go
62 lines
2.2 KiB
Go
package initialize_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/twmb/franz-go/pkg/kgo"
|
|
"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 TestNewServices(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: ""},
|
|
})
|
|
|
|
brokers := initialize.NewBrokers(initialize.BrokersDeps{
|
|
Logger: logger,
|
|
TariffClient: &kgo.Client{},
|
|
})
|
|
|
|
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
|
|
Logger: logger,
|
|
MongoDB: t.Client.Database("test"),
|
|
})
|
|
|
|
services := initialize.NewServices(initialize.ServicesDeps{
|
|
Logger: logger,
|
|
Clients: clients,
|
|
Repositories: repositories,
|
|
Brokers: brokers,
|
|
ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "http://test:8080"},
|
|
})
|
|
|
|
assert.NotNil(t, services)
|
|
assert.NotNil(t, services.AccountService)
|
|
assert.NotNil(t, services.CartService)
|
|
assert.NotNil(t, services.CurrencyService)
|
|
assert.NotNil(t, services.HistoryService)
|
|
assert.NotNil(t, services.WalletService)
|
|
assert.NotNil(t, services.PaymentService)
|
|
assert.NotNil(t, services.PaymentCallbackService)
|
|
assert.NotNil(t, services.TariffBrokerService)
|
|
})
|
|
})
|
|
}
|