javaScriptHttpEndpoint returns a callable function to setup an HTTP endpoint that exposes the given JavaScript source and returns a teardown function to terminate the underlying httptest server instance.
(t *testing.T, js string)
| 1647 | // the given JavaScript source and returns a teardown function to terminate the underlying |
| 1648 | // httptest server instance. |
| 1649 | func javaScriptHttpEndpoint(t *testing.T, js string) func() (path string, teardownFn func()) { |
| 1650 | return func() (path string, teardownFn func()) { |
| 1651 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 1652 | _, err := fmt.Fprint(w, js) |
| 1653 | require.NoError(t, err) |
| 1654 | })) |
| 1655 | teardownFn = func() { ts.Close() } |
| 1656 | return ts.URL, teardownFn |
| 1657 | } |
| 1658 | } |
| 1659 | |
| 1660 | // javaScriptHttpErrorEndpoint returns a callable function to setup an HTTP endpoint that always |
| 1661 | // return StatusInternalServerError and a teardown function to terminate the underlying httptest |
no test coverage detected