(t *testing.T)
| 443 | } |
| 444 | |
| 445 | func TestHandleResponse_200TextPlain_SavesFile(t *testing.T) { |
| 446 | dir := t.TempDir() |
| 447 | origWd, _ := os.Getwd() |
| 448 | os.Chdir(dir) |
| 449 | defer os.Chdir(origWd) |
| 450 | |
| 451 | resp := newApiRespWithStatus(200, []byte("plain text file content"), map[string]string{"Content-Type": "text/plain"}) |
| 452 | |
| 453 | var out, errOut bytes.Buffer |
| 454 | err := HandleResponse(resp, ResponseOptions{Out: &out, ErrOut: &errOut, FileIO: &localfileio.LocalFileIO{}}) |
| 455 | if err != nil { |
| 456 | t.Fatalf("expected no error for 200 text/plain, got: %v", err) |
| 457 | } |
| 458 | if !strings.Contains(errOut.String(), "binary response detected") { |
| 459 | t.Errorf("expected binary detection message, got: %s", errOut.String()) |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | func TestHandleResponse_BinaryWithJq_RejectsNonJSON(t *testing.T) { |
| 464 | resp := newApiResp([]byte("PNG DATA"), map[string]string{"Content-Type": "image/png"}) |
nothing calls this directly
no test coverage detected