(t *testing.T)
| 1511 | } |
| 1512 | |
| 1513 | func 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 | |
| 1548 | func TestEventConfigValidationInvalid(t *testing.T) { |
| 1549 | dbConfigJSON := `{ |
nothing calls this directly
no test coverage detected