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

Function TestWebhookSpecialProperties

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

Source from the content-addressed store, hash-verified

2057}
2058
2059func 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
2099func Benchmark_RestApiGetDocPerformance(b *testing.B) {
2100

Callers

nothing calls this directly

Calls 12

CloseMethod · 0.95
SendAdminRequestMethod · 0.95
JSONDecoderFunction · 0.92
NewRestTesterFunction · 0.85
RequireStatusFunction · 0.85
DoneMethod · 0.80
DecodeMethod · 0.65
ContainsMethod · 0.65
CloseMethod · 0.65
NameMethod · 0.65
AddMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected