generated from PenaSide/GolangTemplate
update common mongo, wit connect url
This commit is contained in:
parent
2086bb1ecd
commit
17ccca3154
@ -79,12 +79,8 @@ func loadConfig() (*models.Config, error) {
|
|||||||
Issuer: os.Getenv("JWT_ISSUER"),
|
Issuer: os.Getenv("JWT_ISSUER"),
|
||||||
},
|
},
|
||||||
Database: mongo.Configuration{
|
Database: mongo.Configuration{
|
||||||
Host: os.Getenv("MONGO_HOST"),
|
URL: os.Getenv("MONGO_URL"),
|
||||||
Port: os.Getenv("MONGO_PORT"),
|
|
||||||
User: os.Getenv("MONGO_USER"),
|
|
||||||
Password: os.Getenv("MONGO_PASSWORD"),
|
|
||||||
DatabaseName: os.Getenv("MONGO_DB_NAME"),
|
DatabaseName: os.Getenv("MONGO_DB_NAME"),
|
||||||
Auth: os.Getenv("MONGO_AUTH"),
|
|
||||||
},
|
},
|
||||||
MailClientCfg: models.MailClientCfg{
|
MailClientCfg: models.MailClientCfg{
|
||||||
ApiUrl: os.Getenv("API_URL"),
|
ApiUrl: os.Getenv("API_URL"),
|
||||||
@ -268,24 +264,12 @@ type t struct {
|
|||||||
|
|
||||||
// todo в будущем в монге будут запрещены некоторые операции, надо будет обновлять
|
// todo в будущем в монге будут запрещены некоторые операции, надо будет обновлять
|
||||||
func validateMongo(cfg mongo.Configuration) error {
|
func validateMongo(cfg mongo.Configuration) error {
|
||||||
if cfg.Host == "" {
|
if cfg.URL == "" {
|
||||||
return fmt.Errorf("mongo host is empty")
|
return fmt.Errorf("mongo URL is empty")
|
||||||
}
|
|
||||||
if cfg.Port == "" {
|
|
||||||
return fmt.Errorf("mongo port is empty")
|
|
||||||
}
|
}
|
||||||
if cfg.DatabaseName == "" {
|
if cfg.DatabaseName == "" {
|
||||||
return fmt.Errorf("mongo database name is empty")
|
return fmt.Errorf("mongo database name is empty")
|
||||||
}
|
}
|
||||||
if cfg.Auth == "" {
|
|
||||||
return fmt.Errorf("mongo database auth is empty")
|
|
||||||
}
|
|
||||||
if cfg.User == "" {
|
|
||||||
return fmt.Errorf("mongo database user is empty")
|
|
||||||
}
|
|
||||||
if cfg.Password == "" {
|
|
||||||
return fmt.Errorf("mongo database password is empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.DatabaseName = "testDBName"
|
cfg.DatabaseName = "testDBName"
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
@ -49,12 +49,8 @@ func TestValidateURLs(t *testing.T) {
|
|||||||
|
|
||||||
func TestValidateMongo(t *testing.T) {
|
func TestValidateMongo(t *testing.T) {
|
||||||
err := validateMongo(mongo.Configuration{
|
err := validateMongo(mongo.Configuration{
|
||||||
Host: "localhost",
|
URL: "mongodb://localhost:27017,localhost:27018,localhost:27019/?replicaSet=rs0&readPreference=primary&ssl=false",
|
||||||
Port: "27020",
|
|
||||||
User: "test",
|
|
||||||
Password: "test",
|
|
||||||
DatabaseName: "admin",
|
DatabaseName: "admin",
|
||||||
Auth: "admin",
|
|
||||||
})
|
})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
@ -109,12 +105,8 @@ func TestLoadConfig(t *testing.T) {
|
|||||||
"GRPC_HOST": "0.0.0.0",
|
"GRPC_HOST": "0.0.0.0",
|
||||||
"GRPC_PORT": "9001",
|
"GRPC_PORT": "9001",
|
||||||
"GRPC_DOMEN": "customer-service:9000",
|
"GRPC_DOMEN": "customer-service:9000",
|
||||||
"MONGO_HOST": "localhost",
|
"MONGO_URL": "mongodb://test:test@localhost:27020/",
|
||||||
"MONGO_PORT": "27020",
|
|
||||||
"MONGO_USER": "test",
|
|
||||||
"MONGO_PASSWORD": "test",
|
|
||||||
"MONGO_DB_NAME": "admin",
|
"MONGO_DB_NAME": "admin",
|
||||||
"MONGO_AUTH": "admin",
|
|
||||||
"KAFKA_BROKERS": "localhost:9092",
|
"KAFKA_BROKERS": "localhost:9092",
|
||||||
"KAFKA_TOPIC_TARIFF": "test-topic",
|
"KAFKA_TOPIC_TARIFF": "test-topic",
|
||||||
"AUTH_MICROSERVICE_URL": "http://localhost:8000/user",
|
"AUTH_MICROSERVICE_URL": "http://localhost:8000/user",
|
||||||
|
@ -18,12 +18,13 @@ services:
|
|||||||
- GRPC_PORT=9065
|
- GRPC_PORT=9065
|
||||||
- GRPC_DOMEN=10.8.0.6:9060
|
- GRPC_DOMEN=10.8.0.6:9060
|
||||||
|
|
||||||
- MONGO_HOST=10.7.0.4
|
# - MONGO_HOST=10.7.0.4
|
||||||
- MONGO_PORT=27017
|
# - MONGO_PORT=27017
|
||||||
- MONGO_USER=$MONGO_USER
|
# - MONGO_USER=$MONGO_USER
|
||||||
- MONGO_PASSWORD=$MONGO_PASSWORD
|
# - MONGO_PASSWORD=$MONGO_PASSWORD
|
||||||
|
- MONGO_URL = TODO
|
||||||
- MONGO_DB_NAME=customer
|
- MONGO_DB_NAME=customer
|
||||||
- MONGO_AUTH=customer
|
# - MONGO_AUTH=customer
|
||||||
- NOTIFICATION_RS_PAY_CHANNEL=-1002338593104
|
- NOTIFICATION_RS_PAY_CHANNEL=-1002338593104
|
||||||
|
|
||||||
- KAFKA_BROKERS=10.8.0.6:9092
|
- KAFKA_BROKERS=10.8.0.6:9092
|
||||||
|
2
go.mod
2
go.mod
@ -5,7 +5,7 @@ go 1.23.2
|
|||||||
toolchain go1.23.3
|
toolchain go1.23.3
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2
|
gitea.pena/PenaSide/common v0.0.0-20241128160655-fe730a08b5f1
|
||||||
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a
|
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a
|
||||||
gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4
|
gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4
|
||||||
github.com/caarlos0/env/v8 v8.0.0
|
github.com/caarlos0/env/v8 v8.0.0
|
||||||
|
4
go.sum
4
go.sum
@ -1,6 +1,10 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2 h1:9U9JJBwWtQV4z/PUCUWCFKurk7sHrT59fGSoXobSdL0=
|
gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2 h1:9U9JJBwWtQV4z/PUCUWCFKurk7sHrT59fGSoXobSdL0=
|
||||||
gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw=
|
gitea.pena/PenaSide/common v0.0.0-20241126121130-cf56ae1e3fb2/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw=
|
||||||
|
gitea.pena/PenaSide/common v0.0.0-20241128144932-b14c114d2569 h1:4PJsYkPNmbpcLAhAHh/jUCJMUwGmGscZ0r9rZeOb30I=
|
||||||
|
gitea.pena/PenaSide/common v0.0.0-20241128144932-b14c114d2569/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw=
|
||||||
|
gitea.pena/PenaSide/common v0.0.0-20241128160655-fe730a08b5f1 h1:w1AAxrlZGmxUI9NAa/0TYsc6sqWWF9yAzQaLL/KxwrM=
|
||||||
|
gitea.pena/PenaSide/common v0.0.0-20241128160655-fe730a08b5f1/go.mod h1:l71j3W1yROhOSfjWZ6wcMuzjBR37gu2ZTcXsorEJoiw=
|
||||||
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a h1:UySqMgaOKNsR42Y6GQXoM2wn/waYNc9cakMUSvbEEAg=
|
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a h1:UySqMgaOKNsR42Y6GQXoM2wn/waYNc9cakMUSvbEEAg=
|
||||||
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU=
|
gitea.pena/PenaSide/linters-golang v0.0.0-20241119212350-2759fa93724a/go.mod h1:gdd+vOT6up9STkEbxa2qESLIMZFjCmRbkcheFQCVgZU=
|
||||||
gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4 h1:y9B4CSPIgiUoaXKyXLZxs1A9hxzDj26F9MH2R6uTkHQ=
|
gitea.pena/PenaSide/trashlog v0.0.0-20241119225515-2fd267647ca4 h1:y9B4CSPIgiUoaXKyXLZxs1A9hxzDj26F9MH2R6uTkHQ=
|
||||||
|
@ -81,11 +81,7 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
|||||||
ExpiresIn: 15 * time.Minute,
|
ExpiresIn: 15 * time.Minute,
|
||||||
},
|
},
|
||||||
Database: mongo.Configuration{
|
Database: mongo.Configuration{
|
||||||
Host: "localhost",
|
URL: "mongodb://test:test@localhost:27020/",
|
||||||
Port: "27017",
|
|
||||||
User: "user",
|
|
||||||
Password: "pass",
|
|
||||||
Auth: "db",
|
|
||||||
DatabaseName: "db",
|
DatabaseName: "db",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -111,11 +107,7 @@ func setDefaultTestingENV(t *testing.T) *models.Config {
|
|||||||
t.Setenv("VERIFICATION_MICROSERVICE_URL", defaultConfiguration.VerificationMicroservice)
|
t.Setenv("VERIFICATION_MICROSERVICE_URL", defaultConfiguration.VerificationMicroservice)
|
||||||
t.Setenv("TEMPLATEGEN_MICROSERVICE_URL", defaultConfiguration.TemplategenMicroserviceURL)
|
t.Setenv("TEMPLATEGEN_MICROSERVICE_URL", defaultConfiguration.TemplategenMicroserviceURL)
|
||||||
|
|
||||||
t.Setenv("MONGO_HOST", defaultConfiguration.ExternalCfg.Database.Host)
|
t.Setenv("MONGO_URL", defaultConfiguration.ExternalCfg.Database.URL)
|
||||||
t.Setenv("MONGO_PORT", defaultConfiguration.ExternalCfg.Database.Port)
|
|
||||||
t.Setenv("MONGO_USER", defaultConfiguration.ExternalCfg.Database.User)
|
|
||||||
t.Setenv("MONGO_PASSWORD", defaultConfiguration.ExternalCfg.Database.Password)
|
|
||||||
t.Setenv("MONGO_AUTH", defaultConfiguration.ExternalCfg.Database.Auth)
|
|
||||||
t.Setenv("MONGO_DB_NAME", defaultConfiguration.ExternalCfg.Database.DatabaseName)
|
t.Setenv("MONGO_DB_NAME", defaultConfiguration.ExternalCfg.Database.DatabaseName)
|
||||||
|
|
||||||
return &defaultConfiguration
|
return &defaultConfiguration
|
||||||
|
@ -3,13 +3,13 @@ package integration
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
"log"
|
|
||||||
"gitea.pena/PenaSide/common/mongo"
|
"gitea.pena/PenaSide/common/mongo"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/client"
|
"gitea.pena/PenaSide/customer/internal/interface/client"
|
||||||
"gitea.pena/PenaSide/customer/internal/interface/repository"
|
"gitea.pena/PenaSide/customer/internal/interface/repository"
|
||||||
codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword"
|
codeword_rpc "gitea.pena/PenaSide/customer/internal/proto/codeword"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/zap"
|
||||||
|
"log"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
@ -29,11 +29,7 @@ func Test_PromoLTV(t *testing.T) {
|
|||||||
|
|
||||||
mdb, err := mongo.Connect(ctx, &mongo.ConnectDeps{
|
mdb, err := mongo.Connect(ctx, &mongo.ConnectDeps{
|
||||||
Configuration: &mongo.Configuration{
|
Configuration: &mongo.Configuration{
|
||||||
Host: "localhost",
|
URL: "mongodb://test:test@localhost:27020/",
|
||||||
Port: "27020",
|
|
||||||
User: "test",
|
|
||||||
Password: "test",
|
|
||||||
Auth: "admin",
|
|
||||||
DatabaseName: "admin",
|
DatabaseName: "admin",
|
||||||
},
|
},
|
||||||
Timeout: 10 * time.Second,
|
Timeout: 10 * time.Second,
|
||||||
|
Loading…
Reference in New Issue
Block a user