(t *testing.T)
| 2057 | } |
| 2058 | |
| 2059 | func TestWebhookSpecialProperties(t *testing.T) { |
| 2060 | |
| 2061 | wg := sync.WaitGroup{} |
| 2062 | |
| 2063 | handler := func(w http.ResponseWriter, r *http.Request) { |
| 2064 | wg.Done() |
| 2065 | |
| 2066 | var body db.Body |
| 2067 | d := base.JSONDecoder(r.Body) |
| 2068 | require.NoError(t, d.Decode(&body)) |
| 2069 | require.Contains(t, body, db.BodyId) |
| 2070 | require.Contains(t, body, db.BodyRev) |
| 2071 | require.Contains(t, body, db.BodyDeleted) |
| 2072 | assert.True(t, body[db.BodyDeleted].(bool)) |
| 2073 | } |
| 2074 | |
| 2075 | s := httptest.NewServer(http.HandlerFunc(handler)) |
| 2076 | defer s.Close() |
| 2077 | |
| 2078 | rtConfig := &RestTesterConfig{ |
| 2079 | DatabaseConfig: &DatabaseConfig{ |
| 2080 | DbConfig: DbConfig{ |
| 2081 | AutoImport: true, |
| 2082 | EventHandlers: &EventHandlerConfig{ |
| 2083 | DocumentChanged: []*EventConfig{ |
| 2084 | {Url: s.URL, Filter: "function(doc){return true;}", HandlerType: "webhook"}, |
| 2085 | }, |
| 2086 | }, |
| 2087 | }, |
| 2088 | }, |
| 2089 | } |
| 2090 | rt := NewRestTester(t, rtConfig) |
| 2091 | defer rt.Close() |
| 2092 | |
| 2093 | wg.Add(1) |
| 2094 | res := rt.SendAdminRequest("PUT", "/{{.keyspace}}/"+t.Name(), `{"foo": "bar", "_deleted": true}`) |
| 2095 | RequireStatus(t, res, http.StatusCreated) |
| 2096 | wg.Wait() |
| 2097 | } |
| 2098 | |
| 2099 | func Benchmark_RestApiGetDocPerformance(b *testing.B) { |
| 2100 |
nothing calls this directly
no test coverage detected