Files
tyapi-server/internal/infrastructure/external/haiyuapi/haiyuapi_service_test.go

31 lines
881 B
Go
Raw Permalink Normal View History

2026-07-05 00:48:37 +08:00
package haiyuapi
import (
"errors"
"testing"
)
func TestMapBusinessError(t *testing.T) {
if err := mapBusinessError(CodeSuccess, ""); err != nil {
t.Fatalf("code 0 should be nil, got %v", err)
}
if !errors.Is(mapBusinessError(CodeQueryEmpty, "查无"), ErrNotFound) {
t.Fatal("expected ErrNotFound for 1000")
}
if !errors.Is(mapBusinessError(CodeBusiness, "业务失败"), ErrDatasource) {
t.Fatal("expected ErrDatasource for 2001")
}
if !errors.Is(mapBusinessError(CodeRequestParam, "参数错误"), ErrSystem) {
t.Fatal("expected ErrSystem for 1003")
}
}
2026-07-23 15:32:41 +08:00
func TestIsQueryBillingProduct(t *testing.T) {
if !isQueryBillingProduct("JRZQK9P2") || !isQueryBillingProduct("JRZQR4N7") {
t.Fatal("洞侦1.0/借贷意向验证3.0 应查空计费")
}
if isQueryBillingProduct("JRZQP8D2") {
t.Fatal("全景雷达BH 查空不计费,不应在白名单中")
}
}