(url string, bodyJson *B)
| 209 | } |
| 210 | |
| 211 | func putRequestJSON[B any](url string, bodyJson *B) error { |
| 212 | payload, err := json.Marshal(bodyJson) |
| 213 | if err != nil { |
| 214 | return err |
| 215 | } |
| 216 | |
| 217 | GinkgoWriter.Printf("PUT %s: %s\n", url, string(payload)) |
| 218 | |
| 219 | req, err := http.NewRequest("PUT", url, bytes.NewBuffer(payload)) |
| 220 | if err != nil { |
| 221 | return err |
| 222 | } |
| 223 | |
| 224 | req.Header.Set("Content-Type", "application/json") |
| 225 | req.Header.Set("Authorization", bearerKey) |
| 226 | |
| 227 | client := &http.Client{} |
| 228 | resp, err := client.Do(req) |
| 229 | if err != nil { |
| 230 | return err |
| 231 | } |
| 232 | defer resp.Body.Close() |
| 233 | |
| 234 | body, err := io.ReadAll(resp.Body) |
| 235 | if err != nil { |
| 236 | return err |
| 237 | } |
| 238 | |
| 239 | if resp.StatusCode < 200 || resp.StatusCode >= 400 { |
| 240 | return fmt.Errorf("unexpected status code: %d, body: %s", resp.StatusCode, string(body)) |
| 241 | } |
| 242 | |
| 243 | return nil |
| 244 | } |
| 245 | |
| 246 | func postInvalidRequest(url string) (error, int) { |
| 247 |
no test coverage detected