MCPcopy Index your code
hub / github.com/dnote/dnote / startCommonTestServer

Function startCommonTestServer

pkg/cli/client/client_test.go:35–51  ·  view source on GitHub ↗

startCommonTestServer starts a test HTTP server that simulates a common set of senarios

()

Source from the content-addressed store, hash-verified

33
34// startCommonTestServer starts a test HTTP server that simulates a common set of senarios
35func 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
53func TestSignIn(t *testing.T) {
54 ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Callers 2

TestSignInFunction · 0.85
TestSignOutFunction · 0.85

Calls 1

WriteHeaderMethod · 0.80

Tested by

no test coverage detected