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

Function postChangesSince

rest/changestest/changes_api_test.go:336–372  ·  view source on GitHub ↗

Basic _changes test with since value

(t *testing.T, rt *rest.RestTester)

Source from the content-addressed store, hash-verified

334
335// Basic _changes test with since value
336func postChangesSince(t *testing.T, rt *rest.RestTester) {
337 rt.CreateUser("bernard", []string{"PBS"})
338
339 cacheWaiter := rt.GetDatabase().NewDCPCachingCountWaiter(t)
340
341 // Put several documents
342 response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs1-0000609", `{"channel":["PBS"]}`)
343 rest.RequireStatus(t, response, 201)
344 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/samevbdiffchannel-0000609", `{"channel":["ABC"]}`)
345 rest.RequireStatus(t, response, 201)
346 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/samevbdiffchannel-0000799", `{"channel":["PBS"]}`)
347 rest.RequireStatus(t, response, 201)
348 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs2-0000609", `{"channel":["PBS"]}`)
349 rest.RequireStatus(t, response, 201)
350 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs3-0000609", `{"channel":["PBS"]}`)
351 rest.RequireStatus(t, response, 201)
352 cacheWaiter.AddAndWait(5)
353
354 changesJSON := `{"style":"all_docs", "heartbeat":300000, "feed":"longpoll", "limit":50, "since":"0"}`
355 changes := rt.PostChanges("/{{.keyspace}}/_changes", changesJSON, "bernard")
356 require.Len(t, changes.Results, 5)
357
358 // Put several more documents, some to the same vbuckets
359 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs1-0000799", `{"value":1, "channel":["PBS"]}`)
360 rest.RequireStatus(t, response, 201)
361 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/abc1-0000609", `{"value":1, "channel":["ABC"]}`)
362 rest.RequireStatus(t, response, 201)
363 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs2-0000799", `{"value":2, "channel":["PBS"]}`)
364 rest.RequireStatus(t, response, 201)
365 response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs4", `{"value":4, "channel":["PBS"]}`)
366 rest.RequireStatus(t, response, 201)
367 cacheWaiter.AddAndWait(4)
368
369 changesJSON = fmt.Sprintf(`{"style":"all_docs", "heartbeat":300000, "feed":"longpoll", "limit":50, "since":"%s"}`, changes.Last_Seq)
370 changes = rt.PostChanges("/{{.keyspace}}/_changes", changesJSON, "bernard")
371 require.Len(t, changes.Results, 3)
372}
373
374func TestPostChangesChannelFilterInteger(t *testing.T) {
375

Callers 1

Calls 8

RequireStatusFunction · 0.92
CreateUserMethod · 0.80
SendAdminRequestMethod · 0.80
AddAndWaitMethod · 0.80
PostChangesMethod · 0.80
LenMethod · 0.65
GetDatabaseMethod · 0.45

Tested by

no test coverage detected