(t *testing.T)
| 210 | case "": |
| 211 | _, _ = io.WriteString(w, `{"id":9,"kind":"imbox","name":"Imbox","next_history_url":"/imbox.json?page=cursor-2","postings":[{"id":1}]}`) |
| 212 | default: |
| 213 | _, _ = io.WriteString(w, `{"id":9,"kind":"imbox","name":"Imbox","postings":[]}`) |
| 214 | } |
| 215 | }), "box", "9", "--all"); err != nil { |
| 216 | t.Fatalf("execute box: %v", err) |
| 217 | } |
| 218 | want := "[/boxes/9.json? /imbox.json?page=cursor-2]" |
| 219 | if got := fmt.Sprint(requests); got != want { |
| 220 | t.Errorf("requests = %s, want %s", got, want) |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | // A box of an unfamiliar kind falls back to the generic route. |
| 225 | func TestBoxCommandFollowsPagesForACustomBox(t *testing.T) { |
| 226 | var requests []string |
| 227 | response, err := runJSONCommand(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 228 | requests = append(requests, r.URL.Path+"?"+r.URL.RawQuery) |
| 229 | w.Header().Set("Content-Type", "application/json") |
| 230 | switch r.URL.Query().Get("page") { |
| 231 | case "": |
| 232 | _, _ = io.WriteString(w, `{"id":17,"kind":"receipts","name":"Receipts","next_history_url":"/boxes/17.json?page=cursor-2","postings":[{"id":1}]}`) |
| 233 | default: |
| 234 | _, _ = io.WriteString(w, `{"id":17,"kind":"receipts","name":"Receipts","next_history_url":"/boxes/17.json?page=cursor-3","postings":[{"id":2}]}`) |
| 235 | } |
| 236 | }), "box", "17", "--limit", "2") |
nothing calls this directly
no test coverage detected