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

Function TestApplyViewQueryOptions

base/bucket_gocb_test.go:1793–1864  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1791}
1792
1793func TestApplyViewQueryOptions(t *testing.T) {
1794
1795 // View query params map (go-couchbase/walrus style)
1796 params := map[string]interface{}{
1797 ViewQueryParamStale: false,
1798 ViewQueryParamReduce: true,
1799 ViewQueryParamStartKey: "foo",
1800 ViewQueryParamEndKey: "bar",
1801 ViewQueryParamInclusiveEnd: true,
1802 ViewQueryParamLimit: uint64(1),
1803 ViewQueryParamIncludeDocs: true, // Ignored -- see https://forums.couchbase.com/t/do-the-viewquery-options-omit-include-docs-on-purpose/12399
1804 ViewQueryParamDescending: true,
1805 ViewQueryParamGroup: true,
1806 ViewQueryParamSkip: uint64(2),
1807 ViewQueryParamGroupLevel: uint64(3),
1808 ViewQueryParamStartKeyDocId: "baz",
1809 ViewQueryParamEndKeyDocId: "blah",
1810 ViewQueryParamKey: "hello",
1811 ViewQueryParamKeys: []interface{}{"a", "b"},
1812 }
1813 ctx := TestCtx(t)
1814 // Call applyViewQueryOptions (method being tested) which modifies viewQuery according to params
1815 viewOpts, err := createViewOptions(ctx, params)
1816 if err != nil {
1817 t.Fatalf("Error calling applyViewQueryOptions: %v", err)
1818 }
1819
1820 // "stale"
1821 assert.Equal(t, gocb.ViewScanConsistencyRequestPlus, viewOpts.ScanConsistency)
1822
1823 // "reduce"
1824 assert.Equal(t, true, viewOpts.Reduce)
1825
1826 // "startkey"
1827 assert.Equal(t, "foo", viewOpts.StartKey)
1828
1829 // "endkey"
1830 assert.Equal(t, "bar", viewOpts.EndKey)
1831
1832 // "inclusive_end"
1833 assert.Equal(t, true, viewOpts.InclusiveEnd)
1834
1835 // "limit"
1836 assert.Equal(t, uint32(1), viewOpts.Limit)
1837
1838 // "descending"
1839 assert.Equal(t, gocb.ViewOrderingDescending, viewOpts.Order)
1840
1841 // "group"
1842 assert.Equal(t, true, viewOpts.Group)
1843
1844 // "skip"
1845 assert.Equal(t, uint32(2), viewOpts.Skip)
1846
1847 // "group_level"
1848 assert.Equal(t, uint32(3), viewOpts.GroupLevel)
1849
1850 // "startkey_docid"

Callers

nothing calls this directly

Calls 4

TestCtxFunction · 0.85
createViewOptionsFunction · 0.85
FatalfMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected