/
yfCaseToHRP.go
39 lines (35 loc) · 1.19 KB
/
yfCaseToHRP.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package hrp
import (
"encoding/json"
"fmt"
"go.uber.org/zap"
"github.com/test-instructor/yangfan/server/global"
mic "github.com/test-instructor/yangfan/server/model/interfacecase"
)
func yangfanTestCaseToHrpCase(testCaseList []mic.HrpCase, debugTalkFilePath string, tcm *ApisCaseModel) error {
for _, testCase := range testCaseList {
apiConfigJson, _ := json.Marshal(testCase.Confing)
var tConfig TConfig
err := json.Unmarshal(apiConfigJson, &tConfig)
if err != nil {
global.GVA_LOG.Error("用例转换出现错误", zap.Error(err))
}
global.GVA_LOG.Debug(fmt.Sprintf("用例id", testCase.ID))
global.GVA_LOG.Debug("case name" + testCase.Name)
toTestCase := ToTestCase{TestSteps: testCase.TestSteps, Config: tcm.Config}
caseJson, _ := json.Marshal(toTestCase)
global.GVA_LOG.Debug("测试用例json格式")
global.GVA_LOG.Debug("\n" + string(caseJson))
tConfig.Path = debugTalkFilePath
tc := &JsonToCase{
JsonString: string(caseJson),
ID: testCase.ID,
DebugTalkFilePath: debugTalkFilePath,
Name: testCase.Name,
Config: &tConfig,
}
testCase, _ := tc.ToTestCase()
tcm.Case = append(tcm.Case, testCase)
}
return nil
}