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

Function TestSetupDbConfigWithSyncFunction

rest/config_test.go:1838–1930  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1836}
1837
1838func TestSetupDbConfigWithSyncFunction(t *testing.T) {
1839 const jsSync = `function (doc, oldDoc) { if (doc.published) { channel("public"); } }`
1840 var tests = []struct {
1841 name string
1842 jsSyncInput func() (path string, teardownFn func())
1843 insecureSkipVerify bool
1844 jsSyncFnExpected string
1845 errExpected error
1846 }{
1847 {
1848 name: "Load inline sync function",
1849 jsSyncInput: inlineJavaScript(jsSync),
1850 insecureSkipVerify: false,
1851 jsSyncFnExpected: jsSync,
1852 errExpected: nil,
1853 },
1854 {
1855 name: "Load sync function from an external http endpoint",
1856 jsSyncInput: javaScriptHttpEndpoint(t, jsSync),
1857 insecureSkipVerify: false,
1858 jsSyncFnExpected: jsSync,
1859 errExpected: nil,
1860 },
1861 {
1862 name: "Load sync function from an external https endpoint with ssl verification enabled",
1863 jsSyncInput: javaScriptHttpsEndpoint(t, jsSync),
1864 insecureSkipVerify: false,
1865 jsSyncFnExpected: "",
1866 errExpected: x509.UnknownAuthorityError{},
1867 },
1868 {
1869 name: "Load sync function from an external https endpoint with ssl verification disabled",
1870 jsSyncInput: javaScriptHttpsEndpoint(t, jsSync),
1871 insecureSkipVerify: true,
1872 jsSyncFnExpected: jsSync,
1873 errExpected: nil,
1874 },
1875 {
1876 name: "Load sync function from an external endpoint that returns an error",
1877 jsSyncInput: javaScriptHttpErrorEndpoint(),
1878 insecureSkipVerify: false,
1879 jsSyncFnExpected: "",
1880 errExpected: errInternalServerError,
1881 },
1882 {
1883 name: "Load sync function from an external file",
1884 jsSyncInput: javaScriptFile(t, jsSync),
1885 insecureSkipVerify: false,
1886 jsSyncFnExpected: jsSync,
1887 errExpected: nil,
1888 },
1889 {
1890 name: "Load sync function from an external empty file",
1891 jsSyncInput: emptyJavaScriptFile(t),
1892 insecureSkipVerify: false,
1893 jsSyncFnExpected: "",
1894 errExpected: nil,
1895 },

Callers

nothing calls this directly

Calls 13

setupMethod · 0.95
PtrFunction · 0.92
TestCtxFunction · 0.92
inlineJavaScriptFunction · 0.85
javaScriptHttpEndpointFunction · 0.85
javaScriptHttpsEndpointFunction · 0.85
javaScriptFileFunction · 0.85
emptyJavaScriptFileFunction · 0.85
missingJavaScriptFileFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected