(t *testing.T)
| 283 | } |
| 284 | |
| 285 | func TestHandleResponse_BinaryAutoSave(t *testing.T) { |
| 286 | dir := t.TempDir() |
| 287 | origWd, _ := os.Getwd() |
| 288 | os.Chdir(dir) |
| 289 | defer os.Chdir(origWd) |
| 290 | |
| 291 | resp := newApiResp([]byte("PNG DATA"), map[string]string{"Content-Type": "image/png"}) |
| 292 | |
| 293 | var out bytes.Buffer |
| 294 | var errOut bytes.Buffer |
| 295 | err := HandleResponse(resp, ResponseOptions{ |
| 296 | Out: &out, |
| 297 | ErrOut: &errOut, |
| 298 | FileIO: &localfileio.LocalFileIO{}, |
| 299 | }) |
| 300 | if err != nil { |
| 301 | t.Fatalf("HandleResponse binary failed: %v", err) |
| 302 | } |
| 303 | if !bytes.Contains(errOut.Bytes(), []byte("binary response detected")) { |
| 304 | t.Errorf("expected binary detection message, got: %s", errOut.String()) |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | func TestHandleResponse_BinaryWithOutput(t *testing.T) { |
| 309 | dir := t.TempDir() |
nothing calls this directly
no test coverage detected