MCPcopy
hub / github.com/larksuite/cli / TestHandleResponse_200TextPlain_SavesFile

Function TestHandleResponse_200TextPlain_SavesFile

internal/client/response_test.go:445–461  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

443}
444
445func 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
463func TestHandleResponse_BinaryWithJq_RejectsNonJSON(t *testing.T) {
464 resp := newApiResp([]byte("PNG DATA"), map[string]string{"Content-Type": "image/png"})

Callers

nothing calls this directly

Calls 5

newApiRespWithStatusFunction · 0.85
HandleResponseFunction · 0.85
GetwdMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected