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

Function TestEventConfigValidationSuccess

rest/api_test.go:1513–1546  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1511}
1512
1513func TestEventConfigValidationSuccess(t *testing.T) {
1514
1515 if !base.UnitTestUrlIsWalrus() {
1516 t.Skip("Skip this test under integration testing")
1517 }
1518
1519 ctx := base.TestCtx(t)
1520 sc := NewServerContext(ctx, &StartupConfig{}, false)
1521 defer sc.Close(ctx)
1522
1523 // Valid config
1524 configJSON := `{"name": "default",
1525 "server": "walrus:",
1526 "bucket": "default",
1527 "event_handlers": {
1528 "max_processes" : 1000,
1529 "wait_for_process" : "15",
1530 "document_changed": [
1531 {"handler": "webhook",
1532 "url": "http://localhost:8081/filtered",
1533 "timeout": 0,
1534 "filter": "function(doc){ return true }"
1535 }
1536 ]
1537 }
1538 }`
1539
1540 var dbConfig DbConfig
1541 err := base.JSONUnmarshal([]byte(configJSON), &dbConfig)
1542 assert.True(t, err == nil)
1543
1544 _, err = sc.AddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig})
1545 assert.True(t, err == nil)
1546}
1547
1548func TestEventConfigValidationInvalid(t *testing.T) {
1549 dbConfigJSON := `{

Callers

nothing calls this directly

Calls 6

CloseMethod · 0.95
AddDatabaseFromConfigMethod · 0.95
UnitTestUrlIsWalrusFunction · 0.92
TestCtxFunction · 0.92
JSONUnmarshalFunction · 0.92
NewServerContextFunction · 0.85

Tested by

no test coverage detected