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

Function TestHandleResponse_BinaryAutoSave

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

Source from the content-addressed store, hash-verified

283}
284
285func 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
308func TestHandleResponse_BinaryWithOutput(t *testing.T) {
309 dir := t.TempDir()

Callers

nothing calls this directly

Calls 6

newApiRespFunction · 0.85
HandleResponseFunction · 0.85
BytesMethod · 0.80
GetwdMethod · 0.65
ContainsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected