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

Function TestSaveResponse_CreatesDir

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

Source from the content-addressed store, hash-verified

185}
186
187func TestSaveResponse_CreatesDir(t *testing.T) {
188 dir := t.TempDir()
189 origWd, _ := os.Getwd()
190 os.Chdir(dir)
191 defer os.Chdir(origWd)
192
193 resp := newApiResp([]byte("data"), map[string]string{"Content-Type": "application/octet-stream"})
194
195 meta, err := SaveResponse(&localfileio.LocalFileIO{}, resp, filepath.Join("sub", "deep", "out.bin"))
196 if err != nil {
197 t.Fatalf("SaveResponse with nested dir failed: %v", err)
198 }
199 savedPath, _ := meta["saved_path"].(string)
200 if _, err := os.Stat(savedPath); err != nil {
201 t.Errorf("expected file to exist at %s", savedPath)
202 }
203}
204
205func TestHandleResponse_JSON(t *testing.T) {
206 body := []byte(`{"code":0,"msg":"ok","data":{"id":"1"}}`)

Callers

nothing calls this directly

Calls 4

newApiRespFunction · 0.85
SaveResponseFunction · 0.85
GetwdMethod · 0.65
StatMethod · 0.65

Tested by

no test coverage detected