startCommonTestServer starts a test HTTP server that simulates a common set of senarios
()
| 33 | |
| 34 | // startCommonTestServer starts a test HTTP server that simulates a common set of senarios |
| 35 | func startCommonTestServer() *httptest.Server { |
| 36 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 37 | // internal server error |
| 38 | if r.URL.String() == "/bad-api/v3/signout" && r.Method == "POST" { |
| 39 | w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 40 | w.WriteHeader(http.StatusInternalServerError) |
| 41 | return |
| 42 | } |
| 43 | |
| 44 | // catch-all |
| 45 | w.Header().Set("Content-Type", "text/html; charset=utf-8") |
| 46 | w.WriteHeader(http.StatusOK) |
| 47 | w.Write([]byte(`<html><body><div id="app-root"></div></body></html>`)) |
| 48 | })) |
| 49 | |
| 50 | return ts |
| 51 | } |
| 52 | |
| 53 | func TestSignIn(t *testing.T) { |
| 54 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
no test coverage detected