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

Function TestAPI_NotFound

cli/cmd/api/api_test.go:178–193  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

176}
177
178func TestAPI_NotFound(t *testing.T) {
179 _, _ = iostreams.SetForTest(t)
180 cli, stop := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
181 w.WriteHeader(http.StatusNotFound)
182 _, _ = w.Write([]byte(`{"error":"missing"}`))
183 })
184 defer stop()
185
186 err := runAPI(context.Background(), &Options{}, &cmdutil.FormatOptions{Mode: cmdutil.FormatText}, cli, "GET", "/api/v1/missing", false)
187 if err == nil {
188 t.Fatal("expected error for 404")
189 }
190 if !cmdutil.IsNotFound(err) {
191 t.Errorf("expected resource.not_found, got %v", err)
192 }
193}
194
195func TestAPI_AcceptsArbitraryMethod(t *testing.T) {
196 _, _ = iostreams.SetForTest(t)

Callers

nothing calls this directly

Calls 6

SetForTestFunction · 0.92
IsNotFoundFunction · 0.92
stopFunction · 0.85
runAPIFunction · 0.85
WriteMethod · 0.80
newTestClientFunction · 0.70

Tested by

no test coverage detected