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)
| 284 | // dispatches to the SDK. Server returns 200 to verify the happy-path lands |
| 285 | // on the response body emit. |
| 286 | func 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. |
nothing calls this directly
no test coverage detected