2026-07-22 17:15:33 +08:00
|
|
|
|
package jiyi
|
|
|
|
|
|
|
|
|
|
|
|
import "testing"
|
|
|
|
|
|
|
|
|
|
|
|
func TestIsEmptyBusinessResult(t *testing.T) {
|
|
|
|
|
|
cases := []struct {
|
|
|
|
|
|
name string
|
|
|
|
|
|
data interface{}
|
|
|
|
|
|
empty bool
|
|
|
|
|
|
}{
|
|
|
|
|
|
{"nil_map", map[string]interface{}{}, true},
|
|
|
|
|
|
{"missing_result", map[string]interface{}{"foo": 1}, true},
|
|
|
|
|
|
{"nil_result", map[string]interface{}{"result": nil}, true},
|
|
|
|
|
|
{"empty_result_map", map[string]interface{}{"result": map[string]interface{}{}}, true},
|
|
|
|
|
|
{"black_tags_zero_not_empty", map[string]interface{}{
|
|
|
|
|
|
"result": map[string]interface{}{
|
|
|
|
|
|
"black_list": "0",
|
|
|
|
|
|
"black_tag04": "0",
|
|
|
|
|
|
},
|
|
|
|
|
|
}, false},
|
|
|
|
|
|
{"score_present", map[string]interface{}{
|
|
|
|
|
|
"result": map[string]interface{}{
|
|
|
|
|
|
"score": "617",
|
|
|
|
|
|
"reason": "",
|
|
|
|
|
|
"contents": map[string]interface{}{"TC_A001": "0"},
|
|
|
|
|
|
},
|
|
|
|
|
|
}, false},
|
|
|
|
|
|
{"all_blank_strings", map[string]interface{}{
|
|
|
|
|
|
"result": map[string]interface{}{
|
|
|
|
|
|
"score": "",
|
|
|
|
|
|
"reason": "",
|
|
|
|
|
|
},
|
|
|
|
|
|
}, true},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, tc := range cases {
|
|
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
|
|
got := isEmptyBusinessResult(tc.data)
|
|
|
|
|
|
if got != tc.empty {
|
|
|
|
|
|
t.Fatalf("got %v want %v", got, tc.empty)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestIsQueryBillingAPIKey(t *testing.T) {
|
|
|
|
|
|
if !isQueryBillingAPIKey("jy000022") || !isQueryBillingAPIKey("jy000042") || !isQueryBillingAPIKey("jy000052") {
|
|
|
|
|
|
t.Fatal("查空计费产品应在白名单中")
|
|
|
|
|
|
}
|
|
|
|
|
|
if isQueryBillingAPIKey("jy000004") {
|
|
|
|
|
|
t.Fatal("信用司南查空不计费,不应在白名单中")
|
|
|
|
|
|
}
|
2026-07-22 17:40:57 +08:00
|
|
|
|
if isQueryBillingAPIKey("jy000002") || isQueryBillingAPIKey("jy000003") {
|
|
|
|
|
|
t.Fatal("全景雷达PD查空不计费,不应在白名单中")
|
|
|
|
|
|
}
|
2026-07-22 17:15:33 +08:00
|
|
|
|
}
|