customer/internal/initialize/services_test.go

58 lines
2.0 KiB
Go
Raw Normal View History

2023-06-22 09:36:43 +00:00
package initialize_test
import (
"testing"
"github.com/stretchr/testify/assert"
2023-07-07 01:57:06 +00:00
"github.com/twmb/franz-go/pkg/kgo"
2023-06-22 09:36:43 +00:00
"go.mongodb.org/mongo-driver/mongo/integration/mtest"
"go.uber.org/zap"
2024-11-18 07:23:41 +00:00
"gitea.pena/PenaSide/customer/internal/initialize"
"gitea.pena/PenaSide/customer/internal/models"
2023-06-22 09:36:43 +00:00
)
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"},
2023-11-05 13:58:41 +00:00
VerificationURL: &models.VerificationMicroserviceURL{Verification: ""},
TemplategenURL: &models.TemplategenMicroserviceURL{Templategen: ""},
2023-06-22 09:36:43 +00:00
})
2023-07-07 01:57:06 +00:00
brokers := initialize.NewBrokers(initialize.BrokersDeps{
Logger: logger,
TariffClient: &kgo.Client{},
})
2023-06-22 09:36:43 +00:00
repositories := initialize.NewRepositories(initialize.RepositoriesDeps{
Logger: logger,
MongoDB: t.Client.Database("test"),
})
services := initialize.NewServices(initialize.ServicesDeps{
Logger: logger,
Clients: clients,
Repositories: repositories,
2023-07-07 01:57:06 +00:00
Brokers: brokers,
2023-06-22 09:36:43 +00:00
ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "http://test:8080"},
})
assert.NotNil(t, services)
assert.NotNil(t, services.HistoryService)
assert.NotNil(t, services.WalletService)
assert.NotNil(t, services.PaymentCallbackService)
2023-07-07 01:57:06 +00:00
assert.NotNil(t, services.TariffBrokerService)
2023-06-22 09:36:43 +00:00
})
})
}