MCPcopy Index your code
hub / github.com/Tencent/WeKnora / TestAPI_AcceptsArbitraryMethod

Function TestAPI_AcceptsArbitraryMethod

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

Source from the content-addressed store, hash-verified

193}
194
195func TestAPI_AcceptsArbitraryMethod(t *testing.T) {
196 _, _ = iostreams.SetForTest(t)
197 var seenMethod string
198 cli, stop := newTestClient(t, func(w http.ResponseWriter, r *http.Request) {
199 seenMethod = r.Method
200 w.WriteHeader(http.StatusOK)
201 })
202 defer stop()
203 for _, m := range []string{"OPTIONS", "PATCH", "TRACE", "CUSTOM"} {
204 t.Run(m, func(t *testing.T) {
205 seenMethod = ""
206 err := runAPI(context.Background(), &Options{}, &cmdutil.FormatOptions{Mode: cmdutil.FormatText}, cli, m, "/api/v1/things", false)
207 if err != nil {
208 t.Fatalf("expected method %q to be accepted, got %v", m, err)
209 }
210 if seenMethod != m {
211 t.Errorf("server saw method %q, want %q", seenMethod, m)
212 }
213 })
214 }
215}
216
217func TestAPI_EmptyMethodRejected(t *testing.T) {
218 _, _ = iostreams.SetForTest(t)

Callers

nothing calls this directly

Calls 4

SetForTestFunction · 0.92
stopFunction · 0.85
runAPIFunction · 0.85
newTestClientFunction · 0.70

Tested by

no test coverage detected