2026-04-25 01:18:30 +08:00

32 lines
926 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Package config 验证 room-service 本地 YAML 配置契约。
package config
import (
"testing"
"time"
)
// TestLoad 验证 room-service 的本地 config.yaml 能被正常读取。
func TestLoad(t *testing.T) {
// 读取真实本地配置,确保端口和关键下游地址没有漂移。
cfg, err := Load("../../configs/config.yaml")
if err != nil {
t.Fatalf("Load failed: %v", err)
}
// room-service 默认只暴露 gRPC端口必须保持 13xxx 约束。
if cfg.GRPCAddr != ":13001" {
t.Fatalf("unexpected grpc addr: %s", cfg.GRPCAddr)
}
// lease TTL 是故障接管抖动窗口的基础参数。
if cfg.LeaseTTL != 10*time.Second {
t.Fatalf("unexpected lease ttl: %s", cfg.LeaseTTL)
}
// SendGift 主链路依赖 wallet-service默认地址必须与本地编排一致。
if cfg.WalletServiceAddr != "127.0.0.1:13004" {
t.Fatalf("unexpected wallet addr: %s", cfg.WalletServiceAddr)
}
}