(t *testing.T)
| 193 | } |
| 194 | |
| 195 | func 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 | |
| 217 | func TestAPI_EmptyMethodRejected(t *testing.T) { |
| 218 | _, _ = iostreams.SetForTest(t) |
nothing calls this directly
no test coverage detected