package zset import "testing" // TestFailureRecordUsesTelecomTemplateVersion covers the telecom branch and the // generic fallback of the carrier label written into a FailureRecord. func TestFailureRecordUsesTelecomTemplateVersion(t *testing.T) { for _, key := range []string{"sim_dx_v1", " SIM_DX_V3 "} { if got := failureFromOutcome(Task{TempKey: key}, TaskOutcome{}, 1); got.Carrier != "telecom" { t.Fatalf("%q carrier = %q", key, got.Carrier) } } if got := failureFromOutcome(Task{TempKey: "sim_dx_v2_future"}, TaskOutcome{}, 1); got.Carrier != "generic" { t.Fatalf("unknown carrier = %q", got.Carrier) } } // TestFailureRecordUsesMobileTemplateSet pins the mobile template list. The list // must stay in sync with carrierMobile's set in // internal/consumer/zset/consumer.go: a template missing here is silently // labelled generic, so failure review and replay would treat a real mobile // channel as the slow generic pool. // // lanshang_8000 / lanshang_8003 are the regression this test was added for -- // they are OneLink shared-token templates whose names omit the sim_onelink_ // prefix, so they were omitted from both the QPS policy and this label. func TestFailureRecordUsesMobileTemplateSet(t *testing.T) { mobileKeys := []string{ "sim_yd_v5", "sim_yd_mock_v5", "sim_onelink_tengyu_v1", "sim_onelink_xuzhou_mobile_v1", "sim_onelink_lelian_v1", "sim_onelink_beixin_v1", "sim_onelink_qianxun_v1", "sim_onelink_henan_xinjing_v1", "sim_onelink_daihe_v1", "lanshang_8000", "lanshang_8003", } for _, key := range mobileKeys { if got := failureFromOutcome(Task{TempKey: key}, TaskOutcome{}, 1); got.Carrier != "mobile" { t.Fatalf("%q carrier = %q, want mobile", key, got.Carrier) } } // Case and padding must not change the classification. if got := failureFromOutcome(Task{TempKey: " LANSHANG_8000 "}, TaskOutcome{}, 1); got.Carrier != "mobile" { t.Fatalf("padded lanshang_8000 carrier = %q, want mobile", got.Carrier) } }