This commit is contained in:
lpf
2026-05-11 13:27:31 +08:00
parent eb781cef25
commit c1cbec551b
2 changed files with 56 additions and 1 deletions

View File

@@ -4,9 +4,12 @@ import (
"context"
"os"
"path/filepath"
"reflect"
"sync/atomic"
"testing"
"time"
"github.com/YspCoder/clawgo/pkg/config"
)
func TestConfigFileFingerprintSameContentIgnoresTouch(t *testing.T) {
@@ -115,3 +118,43 @@ func TestGatewayConfigWatcherTouchDoesNotReload(t *testing.T) {
t.Fatalf("expected touch-only update to skip reload, got %d", got)
}
}
func TestNormalizeHotReloadChannelsConfigIgnoresWeixinRuntimeState(t *testing.T) {
t.Parallel()
base := config.ChannelsConfig{
Weixin: config.WeixinConfig{
Enabled: true,
BaseURL: "https://ilinkai.weixin.qq.com",
DefaultBotID: "bot-a",
Accounts: []config.WeixinAccountConfig{
{
BotID: "bot-a",
BotToken: "token-a",
IlinkUserID: "u-1",
ContextToken: "ctx-a",
GetUpdatesBuf: "buf-a",
},
},
ContextToken: "root-ctx",
GetUpdatesBuf: "root-buf",
},
}
next := base
next.Weixin.ContextToken = "root-ctx-next"
next.Weixin.GetUpdatesBuf = "root-buf-next"
next.Weixin.Accounts[0].ContextToken = "ctx-b"
next.Weixin.Accounts[0].GetUpdatesBuf = "buf-b"
left := normalizeHotReloadChannelsConfig(base)
right := normalizeHotReloadChannelsConfig(next)
if !reflect.DeepEqual(left, right) {
t.Fatalf("expected weixin runtime state changes to be ignored during hot reload comparison")
}
next.Weixin.BaseURL = "https://redirect.example"
right = normalizeHotReloadChannelsConfig(next)
if reflect.DeepEqual(left, right) {
t.Fatalf("expected durable weixin config changes to remain visible to hot reload comparison")
}
}