(t *testing.T)
| 43 | } |
| 44 | |
| 45 | func TestSearchPackages(t *testing.T) { |
| 46 | server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
| 47 | if req.URL.String() != "/api/packages?limit=1&query=foo" { |
| 48 | t.Error("/api/packages?limit=1&query=foo was not called") |
| 49 | } |
| 50 | fmt.Fprint(rw, "{}") |
| 51 | })) |
| 52 | defer server.Close() |
| 53 | |
| 54 | client := request.Client{Client: server.Client(), BaseURL: server.URL} |
| 55 | _, err := client.SearchPackages("foo", 1) |
| 56 | if err != nil { |
| 57 | t.Error(err) |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | func TestHandleServerError(t *testing.T) { |
| 62 | server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { |
nothing calls this directly
no test coverage detected