MCPcopy
hub / github.com/httprunner/httprunner / LoadCurlCase

Function LoadCurlCase

hrp/pkg/convert/from_curl.go:97–119  ·  view source on GitHub ↗

LoadCurlCase loads testcase from one or more curl commands in .txt file

(path string)

Source from the content-addressed store, hash-verified

95
96// LoadCurlCase loads testcase from one or more curl commands in .txt file
97func LoadCurlCase(path string) (*hrp.TCase, error) {
98 cmds, err := readFileLines(path)
99 if err != nil {
100 return nil, err
101 }
102 tCase := &hrp.TCase{
103 Config: &hrp.TConfig{
104 Name: "testcase converted from curl command",
105 },
106 }
107 for _, cmd := range cmds {
108 tSteps, err := LoadCurlSteps(cmd)
109 if err != nil {
110 return nil, err
111 }
112 tCase.TestSteps = append(tCase.TestSteps, tSteps...)
113 }
114 err = tCase.MakeCompat()
115 if err != nil {
116 return nil, err
117 }
118 return tCase, nil
119}
120
121func readFileLines(path string) ([]string, error) {
122 file, err := os.Open(path)

Callers 2

TestLoadCurlCaseFunction · 0.85
loadCaseMethod · 0.85

Calls 3

MakeCompatMethod · 0.95
readFileLinesFunction · 0.85
LoadCurlStepsFunction · 0.85

Tested by 1

TestLoadCurlCaseFunction · 0.68