MCPcopy Create free account
hub / github.com/archlinux-de/pkgstats-cli / TestHandleServerError

Function TestHandleServerError

internal/api/request/client_test.go:61–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59}
60
61func TestHandleServerError(t *testing.T) {
62 server := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
63 rw.WriteHeader(http.StatusBadRequest)
64 fmt.Fprint(rw, "Ignored server message")
65 }))
66 defer server.Close()
67
68 client := request.Client{Client: server.Client(), BaseURL: server.URL}
69 _, err := client.GetPackages("foo")
70 if err != nil && err.Error() != "Bad Request" {
71 t.Errorf("Expected Bad Request, got %v", err)
72 }
73}

Callers

nothing calls this directly

Calls 1

GetPackagesMethod · 0.95

Tested by

no test coverage detected