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

Function TestSyncFunctionErrorLogging

rest/sync_fn_test.go:290–318  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

288}
289
290func TestSyncFunctionErrorLogging(t *testing.T) {
291
292 base.SetUpTestLogging(t, base.LevelInfo, base.KeyHTTP, base.KeyJavascript)
293
294 rtConfig := RestTesterConfig{SyncFn: `
295 function(doc) {
296 console.error("Error");
297 console.log("Log");
298 channel(doc.channel);
299 }`}
300
301 rt := NewRestTester(t, &rtConfig)
302
303 defer rt.Close()
304
305 // Wait for the DB to be ready before attempting to get initial error count
306 rt.WaitForDBOnline()
307
308 numErrors, err := strconv.Atoi(base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().ErrorCount.String())
309 assert.NoError(t, err)
310
311 response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc1", `{"foo": "bar"}`)
312 assert.Equal(t, http.StatusCreated, response.Code)
313
314 numErrorsAfter, err := strconv.Atoi(base.SyncGatewayStats.GlobalStats.ResourceUtilizationStats().ErrorCount.String())
315 assert.NoError(t, err)
316
317 assert.Equal(t, numErrors+1, numErrorsAfter)
318}
319
320func TestSyncFunctionException(t *testing.T) {
321

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
WaitForDBOnlineMethod · 0.95
SendAdminRequestMethod · 0.95
SetUpTestLoggingFunction · 0.92
NewRestTesterFunction · 0.85
StringMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected