chore: 并入 iotlcm-worker-svr 历史到 worker-svr/(原提交 96f0f4e)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:03 +08:00
422 changed files with 80993 additions and 0 deletions
@@ -0,0 +1,38 @@
package lifecycle
import (
"testing"
"github.com/gogf/gf/v2/encoding/gjson"
)
func TestPreferredLifecycleChanKey(t *testing.T) {
tests := []struct {
name string
appBatch bool
snapshot string
card string
want string
}{
{name: "app resolved snapshot wins", appBatch: true, snapshot: " legacy-129 ", card: "stale-1", want: "legacy-129"},
{name: "console keeps card channel", snapshot: "legacy-129", card: " card-112 ", want: "card-112"},
{name: "card fallback", card: " card-112 ", want: "card-112"},
{name: "empty", want: ""},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := preferredLifecycleChanKey(test.appBatch, test.snapshot, test.card); got != test.want {
t.Fatalf("preferredLifecycleChanKey() = %q, want %q", got, test.want)
}
})
}
}
func TestAppBatchUsesSnapshotChannel(t *testing.T) {
if !appBatchUsesSnapshotChannel(gjson.New(map[string]any{"source": "APP"})) {
t.Fatal("app batch should use the resolved snapshot channel")
}
if appBatchUsesSnapshotChannel(gjson.New(map[string]any{"source": "console"})) {
t.Fatal("console batch must continue using the current card channel")
}
}