(t testing.TB, prof *profile.Profile)
| 33 | ) |
| 34 | |
| 35 | func makeTestServer(t testing.TB, prof *profile.Profile) *httptest.Server { |
| 36 | if runtime.GOOS == "nacl" || runtime.GOOS == "js" { |
| 37 | t.Skip("test assumes tcp available") |
| 38 | } |
| 39 | |
| 40 | // Custom http server creator |
| 41 | var server *httptest.Server |
| 42 | serverCreated := make(chan bool) |
| 43 | creator := func(a *plugin.HTTPServerArgs) error { |
| 44 | server = httptest.NewServer(http.HandlerFunc( |
| 45 | func(w http.ResponseWriter, r *http.Request) { |
| 46 | if h := a.Handlers[r.URL.Path]; h != nil { |
| 47 | h.ServeHTTP(w, r) |
| 48 | } |
| 49 | })) |
| 50 | serverCreated <- true |
| 51 | return nil |
| 52 | } |
| 53 | |
| 54 | // Start server and wait for it to be initialized |
| 55 | go serveWebInterface("unused:1234", prof, &plugin.Options{ |
| 56 | Obj: fakeObjTool{}, |
| 57 | UI: &proftest.TestUI{T: t}, |
| 58 | HTTPServer: creator, |
| 59 | }, false) |
| 60 | <-serverCreated |
| 61 | |
| 62 | // Close the server when the test is done. |
| 63 | t.Cleanup(server.Close) |
| 64 | |
| 65 | return server |
| 66 | } |
| 67 | |
| 68 | func TestWebInterface(t *testing.T) { |
| 69 | prof := makeFakeProfile() |
no test coverage detected
searching dependent graphs…