refactor: merge TestCase with TCase, fix converters

This commit is contained in:
lilong.129
2024-08-19 19:42:20 +08:00
parent 448a0bbc67
commit 7b438e5cec
12 changed files with 107 additions and 77 deletions

View File

@@ -49,6 +49,36 @@ func (tc *TestCase) loadStruct() {
}
}
// MakeCompat converts TestCase compatible with Golang engine style
func (tc *TestCase) MakeCompat() (err error) {
defer func() {
if p := recover(); p != nil {
err = fmt.Errorf("[MakeCompat] convert compat testcase error: %v", p)
}
}()
for _, step := range tc.TSteps {
// 1. deal with request body compatibility
convertCompatRequestBody(step.Request)
// 2. deal with validators compatibility
err = convertCompatValidator(step.Validators)
if err != nil {
return err
}
// 3. deal with extract expr including hyphen
convertExtract(step.Extract)
// 4. deal with mobile step compatibility
if step.Android != nil {
convertCompatMobileStep(step.Android)
} else if step.IOS != nil {
convertCompatMobileStep(step.IOS)
}
}
return nil
}
func (tc *TestCase) Dump2JSON(targetPath string) error {
tc.loadStruct()
err := builtin.Dump2JSON(tc, targetPath)