generated from PenaSide/GolangTemplate
test: fix initialize tests
This commit is contained in:
parent
5409141801
commit
091e42f91f
@ -4,6 +4,7 @@ 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"
|
||||
@ -31,11 +32,17 @@ func TestNewAPI(t *testing.T) {
|
||||
PaymentServiceConfiguration: &models.PaymentMicroserviceConfiguration{HostGRPC: "host"},
|
||||
})
|
||||
|
||||
brokers := initialize.NewBrokers(initialize.BrokersDeps{
|
||||
Logger: logger,
|
||||
TariffClient: &kgo.Client{},
|
||||
})
|
||||
|
||||
services := initialize.NewServices(initialize.ServicesDeps{
|
||||
Logger: logger,
|
||||
Repositories: repositories,
|
||||
Clients: clients,
|
||||
ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "domen"},
|
||||
Brokers: brokers,
|
||||
})
|
||||
|
||||
controllers := initialize.NewControllers(initialize.ControllersDeps{
|
||||
|
@ -74,6 +74,10 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
||||
AuthMicroservice: models.AuthMicroserviceConfiguration{
|
||||
URL: defaultAuthURL,
|
||||
},
|
||||
Kafka: models.KafkaConfiguration{
|
||||
Tariff: models.TariffKafkaConfiguration{Topic: "topic"},
|
||||
Brokers: []string{"localhost:8080", "localhost:8081"},
|
||||
},
|
||||
HubadminMicroservice: models.HubadminMicroserviceConfiguration{
|
||||
URL: defaultHubAdminURL,
|
||||
},
|
||||
@ -114,6 +118,9 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
||||
t.Setenv("JWT_ISSUER", defaultConfiguration.Service.JWT.Issuer)
|
||||
t.Setenv("JWT_AUDIENCE", defaultConfiguration.Service.JWT.Audience)
|
||||
|
||||
t.Setenv("KAFKA_BROKERS", "localhost:8080,localhost:8081")
|
||||
t.Setenv("KAFKA_TOPIC_TARIFF", defaultConfiguration.Service.Kafka.Tariff.Topic)
|
||||
|
||||
t.Setenv("AUTH_MICROSERVICE_USER_URL", defaultConfiguration.Service.AuthMicroservice.URL.User)
|
||||
t.Setenv("HUBADMIN_MICROSERVICE_TARIFF_URL", defaultConfiguration.Service.HubadminMicroservice.URL.Tariff)
|
||||
t.Setenv("CURRENCY_MICROSERVICE_TRANSLATE_URL", defaultConfiguration.Service.CurrencyMicroservice.URL.Translate)
|
||||
|
@ -4,6 +4,7 @@ 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"
|
||||
@ -31,10 +32,16 @@ func TestNewControllers(t *testing.T) {
|
||||
MongoDB: t.Client.Database("test"),
|
||||
})
|
||||
|
||||
brokers := initialize.NewBrokers(initialize.BrokersDeps{
|
||||
Logger: logger,
|
||||
TariffClient: &kgo.Client{},
|
||||
})
|
||||
|
||||
services := initialize.NewServices(initialize.ServicesDeps{
|
||||
Logger: logger,
|
||||
Clients: clients,
|
||||
Repositories: repositories,
|
||||
Brokers: brokers,
|
||||
ConfigurationGRPC: &models.ConfigurationGRPC{Domen: "http://test:8080"},
|
||||
})
|
||||
|
||||
|
@ -45,6 +45,12 @@ func NewServices(deps ServicesDeps) *Services {
|
||||
HistoryService: historyService,
|
||||
})
|
||||
|
||||
tariffBrokerService := tariff.New(tariff.Deps{
|
||||
Logger: deps.Logger,
|
||||
Consumer: deps.Brokers.TariffConsumer,
|
||||
Producer: deps.Brokers.TariffProducer,
|
||||
})
|
||||
|
||||
return &Services{
|
||||
WalletService: walletService,
|
||||
HistoryService: historyService,
|
||||
@ -58,12 +64,13 @@ func NewServices(deps ServicesDeps) *Services {
|
||||
Repository: deps.Repositories.CurrencyRepository,
|
||||
}),
|
||||
CartService: cart.New(cart.Deps{
|
||||
Logger: deps.Logger,
|
||||
Repository: deps.Repositories.AccountRepository,
|
||||
HubadminClient: deps.Clients.HubadminClient,
|
||||
DiscountClient: deps.Clients.DiscountClient,
|
||||
WalletService: walletService,
|
||||
HistoryService: historyService,
|
||||
Logger: deps.Logger,
|
||||
Repository: deps.Repositories.AccountRepository,
|
||||
HubadminClient: deps.Clients.HubadminClient,
|
||||
DiscountClient: deps.Clients.DiscountClient,
|
||||
WalletService: walletService,
|
||||
HistoryService: historyService,
|
||||
TariffBrokerService: tariffBrokerService,
|
||||
}),
|
||||
PaymentService: payment.New(payment.Deps{
|
||||
Logger: deps.Logger,
|
||||
@ -77,10 +84,6 @@ func NewServices(deps ServicesDeps) *Services {
|
||||
WalletService: walletService,
|
||||
HistoryService: historyService,
|
||||
}),
|
||||
TariffBrokerService: tariff.New(tariff.Deps{
|
||||
Logger: deps.Logger,
|
||||
Consumer: deps.Brokers.TariffConsumer,
|
||||
Producer: deps.Brokers.TariffProducer,
|
||||
}),
|
||||
TariffBrokerService: tariffBrokerService,
|
||||
}
|
||||
}
|
||||
|
@ -32,15 +32,15 @@ type ServiceConfiguration struct {
|
||||
DiscountMicroservice DiscountMicroserviceConfiguration
|
||||
PaymentMicroservice PaymentMicroserviceConfiguration
|
||||
JWT JWTConfiguration
|
||||
Kafka Kafka
|
||||
Kafka KafkaConfiguration
|
||||
}
|
||||
|
||||
type Kafka struct {
|
||||
Tariff TariffKafka `json:"tariff"`
|
||||
Brokers []string `json:"brokers" env:"KAFKA_BROKERS,required"`
|
||||
type KafkaConfiguration struct {
|
||||
Tariff TariffKafkaConfiguration `json:"tariff"`
|
||||
Brokers []string `json:"brokers" env:"KAFKA_BROKERS,required"`
|
||||
}
|
||||
|
||||
type TariffKafka struct {
|
||||
type TariffKafkaConfiguration struct {
|
||||
Topic string `json:"topic" env:"KAFKA_TOPIC_TARIFF,required"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user