(opChain *chain, path string, pathargs ...interface{})
| 153 | } |
| 154 | |
| 155 | func (r *Request) initPath(opChain *chain, path string, pathargs ...interface{}) { |
| 156 | if len(pathargs) != 0 { |
| 157 | var n int |
| 158 | |
| 159 | var err error |
| 160 | path, err = interpol.WithFunc(path, func(k string, w io.Writer) error { |
| 161 | if n < len(pathargs) { |
| 162 | if pathargs[n] == nil { |
| 163 | opChain.fail(AssertionFailure{ |
| 164 | Type: AssertValid, |
| 165 | Actual: &AssertionValue{pathargs}, |
| 166 | Errors: []error{ |
| 167 | fmt.Errorf("unexpected nil argument at index %d", n), |
| 168 | }, |
| 169 | }) |
| 170 | } else { |
| 171 | mustWrite(w, fmt.Sprint(pathargs[n])) |
| 172 | } |
| 173 | } else { |
| 174 | mustWrite(w, "{") |
| 175 | mustWrite(w, k) |
| 176 | mustWrite(w, "}") |
| 177 | } |
| 178 | n++ |
| 179 | return nil |
| 180 | }) |
| 181 | |
| 182 | if err != nil { |
| 183 | opChain.fail(AssertionFailure{ |
| 184 | Type: AssertValid, |
| 185 | Actual: &AssertionValue{path}, |
| 186 | Errors: []error{ |
| 187 | errors.New("invalid interpol string"), |
| 188 | err, |
| 189 | }, |
| 190 | }) |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | r.path = path |
| 195 | } |
| 196 | |
| 197 | func (r *Request) initReq(opChain *chain, method string) { |
| 198 | httpReq, err := r.config.RequestFactory.NewRequest(method, r.config.BaseURL, nil) |
no test coverage detected