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

Method initializeCollections

rest/utilities_testing.go:1542–1577  ·  view source on GitHub ↗
(collections []string)

Source from the content-addressed store, hash-verified

1540}
1541
1542func (bt *BlipTester) initializeCollections(collections []string) {
1543 getCollectionsRequest := blip.NewRequest()
1544 getCollectionsRequest.SetProfile(db.MessageGetCollections)
1545
1546 checkpointIDs := make([]string, len(collections))
1547 for i := range checkpointIDs {
1548 checkpointIDs[i] = "0"
1549 }
1550
1551 requestBody := db.GetCollectionsRequestBody{
1552 Collections: collections,
1553 CheckpointIDs: checkpointIDs,
1554 }
1555 body, err := base.JSONMarshal(requestBody)
1556 require.NoError(bt.restTester.TB(), err)
1557
1558 getCollectionsRequest.SetBody(body)
1559 sent := bt.sender.Send(getCollectionsRequest)
1560 require.True(bt.restTester.TB(), sent)
1561
1562 type CollectionsResponseEntry struct {
1563 LastSequence *int `json:"last_sequence"`
1564 Rev *string `json:"rev"`
1565 }
1566
1567 response, err := getCollectionsRequest.Response().Body()
1568 require.NoError(bt.restTester.TB(), err)
1569
1570 var collectionResponse []*CollectionsResponseEntry
1571 err = base.JSONUnmarshal(response, &collectionResponse)
1572 require.NoError(bt.restTester.TB(), err)
1573
1574 for _, perCollectionResponse := range collectionResponse {
1575 require.NotNil(bt.restTester.TB(), perCollectionResponse)
1576 }
1577}
1578
1579// newRequest returns a blip msg with a collection property enabled. This function is only ssafe to call if there is a single collection running.
1580func (bt *BlipTester) newRequest() *blip.Message {

Callers 1

createBlipTesterWithSpecFunction · 0.95

Calls 6

JSONMarshalFunction · 0.92
JSONUnmarshalFunction · 0.92
TBMethod · 0.65
SendMethod · 0.65
BodyMethod · 0.45
ResponseMethod · 0.45

Tested by

no test coverage detected