LoadCurlCase loads testcase from one or more curl commands in .txt file
(path string)
| 95 | |
| 96 | // LoadCurlCase loads testcase from one or more curl commands in .txt file |
| 97 | func 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 | |
| 121 | func readFileLines(path string) ([]string, error) { |
| 122 | file, err := os.Open(path) |