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

Function TestRevocationsWithQueryLimitChangesLimit

rest/revocation_test.go:1162–1209  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1160}
1161
1162func TestRevocationsWithQueryLimitChangesLimit(t *testing.T) {
1163 defer db.SuspendSequenceBatching()()
1164
1165 revocationTester, rt := InitScenario(t, &RestTesterConfig{
1166 DatabaseConfig: &DatabaseConfig{DbConfig: DbConfig{
1167 QueryPaginationLimit: base.Ptr(2),
1168 CacheConfig: &CacheConfig{
1169 RevCacheConfig: &RevCacheConfig{
1170 MaxItemCount: base.Ptr(uint32(0)),
1171 },
1172 ChannelCacheConfig: &ChannelCacheConfig{
1173 MaxNumber: base.Ptr(0),
1174 },
1175 },
1176 }},
1177 })
1178 defer rt.Close()
1179
1180 revocationTester.addRole("user", "foo")
1181 revocationTester.addRoleChannel("foo", "ch1")
1182
1183 revocationTester.fillToSeq(9)
1184 _ = rt.PutDoc("doc1", `{"channels": ["ch1"]}`)
1185 _ = rt.PutDoc("doc2", `{"channels": ["ch1"]}`)
1186 _ = rt.PutDoc("doc3", `{"channels": ["ch1"]}`)
1187
1188 changes := revocationTester.getChanges("0", 4)
1189
1190 revocationTester.removeRole("user", "foo")
1191
1192 rt.WaitForPendingChanges()
1193 waitForUserChangesWithLimit := func(sinceVal interface{}, limit int) ChangesResults {
1194 var changesRes ChangesResults
1195 err := rt.WaitForCondition(func() bool {
1196 changesRes = rt.GetChanges(fmt.Sprintf("/{{.keyspace}}/_changes?since=%v&revocations=true&limit=%d", sinceVal, limit), "user")
1197 return len(changesRes.Results) == limit
1198 })
1199 assert.NoError(t, err)
1200 return changesRes
1201 }
1202
1203 sinceVal := changes.Last_Seq
1204 changes = waitForUserChangesWithLimit(sinceVal, 2)
1205 assert.Len(t, changes.Results, 2)
1206
1207 changes = waitForUserChangesWithLimit(sinceVal, 3)
1208 assert.Len(t, changes.Results, 3)
1209}
1210
1211func TestRevocationUserHasDocAccessDocNotFound(t *testing.T) {
1212 if !base.UnitTestUrlIsWalrus() {

Callers

nothing calls this directly

Calls 14

SuspendSequenceBatchingFunction · 0.92
PtrFunction · 0.92
InitScenarioFunction · 0.85
addRoleChannelMethod · 0.80
fillToSeqMethod · 0.80
PutDocMethod · 0.80
getChangesMethod · 0.80
WaitForConditionMethod · 0.80
CloseMethod · 0.65
GetChangesMethod · 0.65
LenMethod · 0.65
addRoleMethod · 0.45

Tested by

no test coverage detected