2bec257289
iotlcm-worker-svr:异步执行中枢(RabbitMQ 消费者 + 全量同步编排)。 - Go module:iotlcm-worker-svr → git.5iot.com/iotlcm-public/iotlcm-worker-svr(214 文件) - 凭据与内部标识脱敏:MySQL/Redis 凭据、私网与生产 IP、内网域名、 库名 xiujie_admin → iotlcm、哨兵名占位 - 159 处真实手机号 → 合法 11 位编造号(保留号段与后 4 位,维持互异, 不破坏「校验 MSISDN 格式」等测试断言) - 移除内部资产:CI 触发器、Jenkins 触发测试文档、预演门禁与镜像 digest 记录 - Dockerfile 改用公共基础镜像(golang:1.25-alpine → alpine:3.23), 移除写死的 git 凭据 - README 重写(架构/全量同步模型/配置/已知失败),补 Apache-2.0 LICENSE,LF 行尾 + .gitattributes 已知:3 个测试包在源仓同一提交上同样失败(client/upstream、 service/allocate、service/inbound),属既有缺陷,本仓未引入亦未修复。
38 lines
1.3 KiB
Go
38 lines
1.3 KiB
Go
package warningconfig
|
|
|
|
import (
|
|
"github.com/gogf/gf/v2/encoding/gjson"
|
|
"testing"
|
|
)
|
|
|
|
func TestNotificationFieldPresenceSurvivesSnapshot(t *testing.T) {
|
|
for _, supplied := range []bool{false, true} {
|
|
data := map[string]any{"itemType": 1, "warnUnit": 1, "firstWarn": 100, "isEnabled": 1}
|
|
if supplied {
|
|
data["appNotifyEnabled"] = 0
|
|
data["wxTemplateId"] = ""
|
|
}
|
|
config, err := configFromBatchInfo(gjson.New(data))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if config.AppNotifyProvided != supplied || config.WxTemplateProvided != supplied {
|
|
t.Fatalf("presence lost: %+v", config)
|
|
}
|
|
detail := &Detail{Config: config}
|
|
snapshot := detail.Snapshot(config)
|
|
restored := configFromDetailSnapshot(snapshot, Config{})
|
|
if restored.AppNotifyProvided != supplied || restored.WxTemplateProvided != supplied {
|
|
t.Fatalf("snapshot presence lost: %+v", restored)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestNotificationSnapshotPreservesFallbackWhenAbsent(t *testing.T) {
|
|
fallback := Config{AppNotifyEnabled: 1, AppNotifyProvided: true, WxTemplateID: "existing", WxTemplateProvided: true}
|
|
restored := configFromDetailSnapshot(gjson.New(map[string]any{"configSet": true, "warnUnit": 1}), fallback)
|
|
if restored.AppNotifyEnabled != 1 || restored.WxTemplateID != "existing" {
|
|
t.Fatalf("fallback overwritten: %+v", restored)
|
|
}
|
|
}
|