youtu_grpc/pkg/config/get_config_test.go
xiabin c7f5f9828a
All checks were successful
Auth & User Management Service CI / build-services (app/auth_service/Dockerfile, auth_service, auth_service) (push) Successful in 40s
Auth & User Management Service CI / build-services (app/douyin_ecpm_calculation_service/Dockerfile, douyin_ecpm_calculation_service, douyin_ecpm_calculation_service) (push) Successful in 38s
Auth & User Management Service CI / build-services (app/ranking_management/Dockerfile, ranking_management, ranking_management) (push) Successful in 42s
Auth & User Management Service CI / build-services (app/user_management/Dockerfile, user_manager, user_management) (push) Successful in 39s
Auth & User Management Service CI / start-services (push) Successful in 4s
1
2025-02-11 16:54:00 +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))
}