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

Method WaitForVersion

rest/utilities_testing_resttester.go:211–233  ·  view source on GitHub ↗

WaitForVersion retries a GET for a given document version until it returns 200 or 201 for a given document and revision. If version is not found, the test will fail.

(docID string, version DocVersion)

Source from the content-addressed store, hash-verified

209
210// WaitForVersion retries a GET for a given document version until it returns 200 or 201 for a given document and revision. If version is not found, the test will fail.
211func (rt *RestTester) WaitForVersion(docID string, version DocVersion) {
212 if version.RevTreeID == "" {
213 require.NotEqual(rt.TB(), "", version.CV.String(), "Expected CV if RevTreeID is empty for version %#v in WaitForVersion", version)
214 }
215 require.EventuallyWithT(rt.TB(), func(c *assert.CollectT) {
216 rawResponse := rt.SendAdminRequest("GET", "/{{.keyspace}}/"+docID, "")
217 if !assert.Contains(c, []int{200, 201}, rawResponse.Code, "Unexpected status code for %s", rawResponse.Body.String()) {
218 return
219 }
220 var body db.Body
221 require.NoError(rt.TB(), base.JSONUnmarshal(rawResponse.Body.Bytes(), &body))
222 if version.RevTreeID != "" {
223 assert.Equal(c, version.RevTreeID, body.ExtractRev())
224 }
225 if version.CV.IsEmpty() {
226 return
227 }
228 if !assert.Contains(c, body, db.BodyCV) {
229 return
230 }
231 assert.Equal(c, version.CV.String(), body[db.BodyCV].(string))
232 }, 10*time.Second, 50*time.Millisecond)
233}
234
235func (rt *RestTester) WaitForVersionRevIDOnly(docID string, version DocVersion) {
236 version.CV = db.Version{} // empty cv so WaitForVersion only asserts on revID

Calls 8

TBMethod · 0.95
SendAdminRequestMethod · 0.95
ExtractRevMethod · 0.95
JSONUnmarshalFunction · 0.92
StringMethod · 0.65
ContainsMethod · 0.65
EqualMethod · 0.45
IsEmptyMethod · 0.45