(t *testing.T)
| 67 | } |
| 68 | |
| 69 | func TestSearchReturnsAPIError(t *testing.T) { |
| 70 | newTestServer(t, func(w http.ResponseWriter, r *http.Request) { |
| 71 | w.WriteHeader(http.StatusUnauthorized) |
| 72 | _, _ = w.Write([]byte(`{"detail":"Invalid API key"}`)) |
| 73 | }) |
| 74 | |
| 75 | client := NewClient() |
| 76 | client.ApiKey.Value = "bad" |
| 77 | |
| 78 | _, err := client.Search("anything") |
| 79 | require.ErrorContains(t, err, "401") |
| 80 | require.ErrorContains(t, err, "Invalid API key") |
| 81 | } |
| 82 | |
| 83 | func TestSearchReturnsEmptyWhenNoResults(t *testing.T) { |
| 84 | newTestServer(t, func(w http.ResponseWriter, r *http.Request) { |
nothing calls this directly
no test coverage detected