44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
// TestLoad 验证 gateway-service 的本地 config.yaml 能被正常读取。
|
|
func TestLoad(t *testing.T) {
|
|
cfg, err := Load("../../configs/config.yaml")
|
|
if err != nil {
|
|
t.Fatalf("Load failed: %v", err)
|
|
}
|
|
|
|
if cfg.HTTPAddr != ":13000" {
|
|
t.Fatalf("unexpected http addr: %s", cfg.HTTPAddr)
|
|
}
|
|
|
|
if cfg.RoomServiceAddr != "127.0.0.1:13001" {
|
|
t.Fatalf("unexpected room addr: %s", cfg.RoomServiceAddr)
|
|
}
|
|
}
|
|
|
|
// TestLoadTencentExample 验证腾讯云 IM 线上模板字段能被 gateway 正确解析。
|
|
func TestLoadTencentExample(t *testing.T) {
|
|
cfg, err := Load("../../configs/config.tencent.example.yaml")
|
|
if err != nil {
|
|
t.Fatalf("Load tencent example failed: %v", err)
|
|
}
|
|
|
|
if cfg.TencentIM.SDKAppID == 0 {
|
|
t.Fatalf("sdk_app_id template must be present")
|
|
}
|
|
if cfg.TencentIM.SecretKey == "" || cfg.TencentIM.CallbackAuthToken == "" {
|
|
t.Fatalf("secret and callback token templates must be present")
|
|
}
|
|
if cfg.TencentIM.CallbackURL == "" {
|
|
t.Fatalf("callback_url template must be present")
|
|
}
|
|
if cfg.TencentIM.UserSigTTL != 24*time.Hour {
|
|
t.Fatalf("unexpected usersig ttl: %s", cfg.TencentIM.UserSigTTL)
|
|
}
|
|
}
|