youtu_grpc/pkg/config/get_config_test.go
xiabin 90f1d6eecf
All checks were successful
Auth & User Management Service CI / build-services (app/douyin_ecpm_calculation_service/Dockerfile, douyin_ecpm_calculation_service, douyin_ecpm_calculation_service) (push) Successful in 36s
Auth & User Management Service CI / build-services (app/ranking_management/Dockerfile, ranking_management, ranking_management) (push) Successful in 41s
Auth & User Management Service CI / build-services (app/auth_service/Dockerfile, auth_service, auth_service) (push) Successful in 41s
Auth & User Management Service CI / build-services (app/user_management/Dockerfile, user_manager, user_management) (push) Successful in 38s
Auth & User Management Service CI / start-services (push) Successful in 5s
各服务数据库逻辑拆分
更新用户id为Sonyflake

添加gitea actions(ci/cd)

配置文件读取方式改为从ETCD读取

修改go module名称与gitea一致
2025-02-11 18:31:28 +08:00

45 lines
1.0 KiB
Go

package config
import (
"encoding/json"
"fmt"
"testing"
)
func TestGetConfig(t *testing.T) {
type args struct {
c *Config
serverName string
}
tests := []struct {
name string
args args
wantErr bool
}{
// TODO: Add test cases.
{"test", args{c: &Config{}, serverName: "test"}, false},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := GetConfig(tt.args.c, tt.args.serverName); (err != nil) != tt.wantErr {
t.Errorf("GetConfig() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}
func TestGenConfig(t *testing.T) {
var c Config
c.RpcServerConf.ListenOn = "0.0.0.0:8081"
c.Mode = "dev"
c.Mysql = "root:youtu!0113@tcp(192.168.0.47:3306)/ecpm?charset=utf8mb4&parseTime=True&loc=Local"
c.Redis = []Redis{{Host: "192.168.0.47:6379"}}
c.RpcServerConf.Etcd.Hosts = append(c.RpcServerConf.Etcd.Hosts, "192.168.0.47:2379")
c.RpcServerConf.Etcd.Key = "user_management.rpc"
b, err := json.Marshal(c)
if err != nil {
t.Fatal(err)
}
fmt.Println(string(b))
}