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

Function TestAPI_PathWithoutSlash

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

Source from the content-addressed store, hash-verified

227}
228
229func TestAPI_PathWithoutSlash(t *testing.T) {
230 _, _ = iostreams.SetForTest(t)
231 err := runAPI(context.Background(), &Options{}, &cmdutil.FormatOptions{Mode: cmdutil.FormatText}, nil, "GET", "api/v1/things", false)
232 if err == nil {
233 t.Fatal("expected error for missing leading slash")
234 }
235 var ce *cmdutil.Error
236 if !asTypedError(err, &ce) || ce.Code != cmdutil.CodeInputInvalidArgument {
237 t.Errorf("expected input.invalid_argument, got %v", err)
238 }
239}
240
241// withRootHarness wraps `weknora api ...` under a synthetic root cmd that
242// registers the global persistent flags (mirrors addGlobalFlags in

Callers

nothing calls this directly

Calls 3

SetForTestFunction · 0.92
runAPIFunction · 0.85
asTypedErrorFunction · 0.85

Tested by

no test coverage detected