MCPcopy
hub / github.com/Tencent/WeKnora / TestAPI_DELETE_WithYes_Proceeds

Function TestAPI_DELETE_WithYes_Proceeds

cli/cmd/api/api_test.go:286–308  ·  view source on GitHub ↗

TestAPI_DELETE_WithYes_Proceeds: -y/--yes opt-in skips confirmation and dispatches to the SDK. Server returns 200 to verify the happy-path lands on the response body emit.

(t *testing.T)

Source from the content-addressed store, hash-verified

284// dispatches to the SDK. Server returns 200 to verify the happy-path lands
285// on the response body emit.
286func TestAPI_DELETE_WithYes_Proceeds(t *testing.T) {
287 iostreams.SetForTest(t)
288 called := false
289 cli, stop := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
290 if r.Method != http.MethodDelete {
291 t.Errorf("expected DELETE, got %s", r.Method)
292 }
293 called = true
294 w.WriteHeader(http.StatusOK)
295 })
296 defer stop()
297 f := &cmdutil.Factory{
298 Client: func() (*sdk.Client, error) { return cli, nil },
299 Prompter: func() prompt.Prompter { return prompt.AgentPrompter{} },
300 }
301 root := withRootHarness(NewCmd(f), "/api/v1/knowledge-bases/kb_xxx", "-X", "DELETE", "-y")
302 if err := root.Execute(); err != nil {
303 t.Fatalf("execute: %v", err)
304 }
305 if !called {
306 t.Error("DELETE handler not called - confirmation may have blocked")
307 }
308}
309
310// asTypedError is a tiny wrapper around errors.As that keeps the call sites
311// concise. Returns true on success, populating dst.

Callers

nothing calls this directly

Calls 7

SetForTestFunction · 0.92
stopFunction · 0.85
newTestClientFunction · 0.70
withRootHarnessFunction · 0.70
NewCmdFunction · 0.70
ExecuteMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected