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("信用司南查空不计费,不应在白名单中") } }