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

Function TestGetDocWithCV

rest/doc_api_test.go:180–228  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

178}
179
180func TestGetDocWithCV(t *testing.T) {
181 rt := NewRestTesterPersistentConfig(t)
182 defer rt.Close()
183
184 docID := "doc1"
185 docVersion := rt.PutDoc(docID, `{"foo": "bar"}`)
186 testCases := []struct {
187 name string
188 url string
189 output string
190 headers map[string]string
191 multipart bool
192 }{
193 {
194 name: "get doc with cv",
195 url: "/{{.keyspace}}/doc1",
196 output: fmt.Sprintf(`{"_id":"%s","_rev":"%s","_cv":"%s","foo":"bar"}`, docID, docVersion.RevTreeID, docVersion.CV),
197 },
198 {
199 name: "get doc with open_revs=all and cv no multipart",
200 url: "/{{.keyspace}}/doc1?open_revs=all",
201 output: fmt.Sprintf(`[{"ok": {"_id":"%s","_rev":"%s","_cv":"%s","foo":"bar"}}]`, docID, docVersion.RevTreeID, docVersion.CV),
202 headers: map[string]string{
203 "Accept": "application/json",
204 },
205 },
206
207 {
208 name: "get doc with open_revs=all and cv",
209 url: "/{{.keyspace}}/doc1?open_revs=all",
210 output: fmt.Sprintf(`{"_id":"%s","_rev":"%s","_cv":"%s","foo":"bar"}`, docID, docVersion.RevTreeID, docVersion.CV),
211 multipart: true,
212 },
213 }
214 for _, testCase := range testCases {
215 t.Run(testCase.name, func(t *testing.T) {
216 response := rt.SendAdminRequestWithHeaders("GET", testCase.url, "", testCase.headers)
217 RequireStatus(t, response, http.StatusOK)
218 output := response.BodyString()
219 if testCase.multipart {
220 multipartOutput := readMultiPartBody(t, response)
221 require.Len(t, multipartOutput, 1)
222 output = multipartOutput[0]
223 }
224 assert.JSONEq(t, testCase.output, output)
225 })
226 }
227
228}
229
230func TestBulkGetWithCV(t *testing.T) {
231 rt := NewRestTesterPersistentConfig(t)

Callers

nothing calls this directly

Calls 9

RequireStatusFunction · 0.85
readMultiPartBodyFunction · 0.85
PutDocMethod · 0.80
BodyStringMethod · 0.80
CloseMethod · 0.65
RunMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected