add qygl23t7

This commit is contained in:
2025-07-30 00:51:22 +08:00
parent 83530c0f9b
commit 723c418a1b
38 changed files with 999 additions and 785 deletions

View File

@@ -0,0 +1,62 @@
package services
import (
"context"
"encoding/json"
"testing"
"tyapi-server/internal/application/api/commands"
)
// 基础测试结构体
type apiRequestServiceTestSuite struct {
t *testing.T
ctx context.Context
service *ApiRequestService
}
// 初始化测试套件
func newApiRequestServiceTestSuite(t *testing.T) *apiRequestServiceTestSuite {
// 这里可以初始化依赖的mock或fake对象
// 例如mockProcessorDeps := &MockProcessorDeps{}
// service := &ApiRequestService{processorDeps: mockProcessorDeps}
// 这里只做基础架构具体mock实现后续补充
return &apiRequestServiceTestSuite{
t: t,
ctx: context.Background(),
service: nil, // 这里后续可替换为实际service或mock
}
}
// 示例测试PreprocessRequestApi方法仅结构具体mock和断言后续补充
func TestApiRequestService_PreprocessRequestApi(t *testing.T) {
suite := newApiRequestServiceTestSuite(t)
// 假设有一个mock processor和注册
// RequestProcessors = map[string]processors.ProcessorFunc{
// "MOCKAPI": func(ctx context.Context, params []byte, deps interface{}) ([]byte, error) {
// return []byte("ok"), nil
// },
// }
// 这里仅做结构示例
apiCode := "QYGL23T7"
params := map[string]string{
"code": "91460000MAE471M58X",
"name": "海南天远大数据科技有限公司",
"legalPersonName": "刘福思",
}
paramsByte, err := json.Marshal(params)
if err != nil {
t.Fatalf("参数序列化失败: %v", err)
}
options := commands.ApiCallOptions{} // 实际应为*commands.ApiCallOptions
// 由于service为nil这里仅做断言结构示例
if suite.service != nil {
resp, err := suite.service.PreprocessRequestApi(suite.ctx, apiCode, paramsByte, &options)
if err != nil {
t.Errorf("PreprocessRequestApi 调用出错: %v", err)
}
t.Logf("PreprocessRequestApi 返回结果: %s", string(resp))
}
}