(t *testing.T)
| 288 | } |
| 289 | |
| 290 | func 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 | |
| 320 | func TestSyncFunctionException(t *testing.T) { |
| 321 |
nothing calls this directly
no test coverage detected