MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / javaScriptHttpsEndpoint

Function javaScriptHttpsEndpoint

rest/config_test.go:1676–1685  ·  view source on GitHub ↗

javaScriptHttpsEndpoint returns a callable function to setup an HTTPS endpoint that exposes the given JavaScript source and returns a teardown function to terminate the underlying httptest server instance.

(t *testing.T, js string)

Source from the content-addressed store, hash-verified

1674// the given JavaScript source and returns a teardown function to terminate the underlying
1675// httptest server instance.
1676func javaScriptHttpsEndpoint(t *testing.T, js string) func() (path string, teardownFn func()) {
1677 return func() (path string, teardownFn func()) {
1678 ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
1679 _, err := fmt.Fprint(w, js)
1680 require.NoError(t, err)
1681 }))
1682 teardownFn = func() { ts.Close() }
1683 return ts.URL, teardownFn
1684 }
1685}
1686
1687func TestLoadJavaScript(t *testing.T) {
1688 const js = `function (doc, oldDoc) { if (doc.published) { channel("public"); } }`

Calls 1

CloseMethod · 0.65

Tested by

no test coverage detected