Validate retrieval of various document body types using include_docs.
(t *testing.T)
| 1756 | |
| 1757 | // Validate retrieval of various document body types using include_docs. |
| 1758 | func TestChangesIncludeDocs(t *testing.T) { |
| 1759 | base.SetUpTestLogging(t, base.LevelInfo, base.KeyNone) |
| 1760 | |
| 1761 | rtConfig := rest.RestTesterConfig{SyncFn: `function(doc) {channel(doc.channels)}`} |
| 1762 | rt := rest.NewRestTester(t, &rtConfig) |
| 1763 | testDB := rt.GetDatabase() |
| 1764 | testDB.RevsLimit = 3 |
| 1765 | rt.GetDatabase().EnableAllowConflicts(rt.TB()) |
| 1766 | defer rt.Close() |
| 1767 | collection, ctx := rt.GetSingleTestDatabaseCollection() |
| 1768 | |
| 1769 | rt.CreateUser("user1", []string{"alpha", "beta"}) |
| 1770 | |
| 1771 | // Create docs for each scenario |
| 1772 | // Active |
| 1773 | _, err := updateTestDoc(rt, "doc_active", "", `{"type": "active", "channels":["alpha"]}`) |
| 1774 | assert.NoError(t, err, "Error updating doc") |
| 1775 | |
| 1776 | // Multi-revision |
| 1777 | var revid string |
| 1778 | revid, err = updateTestDoc(rt, "doc_multi_rev", "", `{"type": "active", "channels":["alpha"], "v":1}`) |
| 1779 | assert.NoError(t, err, "Error updating doc") |
| 1780 | _, err = updateTestDoc(rt, "doc_multi_rev", revid, `{"type": "active", "channels":["alpha"], "v":2}`) |
| 1781 | assert.NoError(t, err, "Error updating doc") |
| 1782 | |
| 1783 | // Tombstoned |
| 1784 | revid, err = updateTestDoc(rt, "doc_tombstone", "", `{"type": "tombstone", "channels":["alpha"]}`) |
| 1785 | assert.NoError(t, err, "Error updating doc") |
| 1786 | response := rt.SendAdminRequest("DELETE", fmt.Sprintf("/{{.keyspace}}/doc_tombstone?rev=%s", revid), "") |
| 1787 | rest.RequireStatus(t, response, 200) |
| 1788 | |
| 1789 | // Removed |
| 1790 | revid, err = updateTestDoc(rt, "doc_removed", "", `{"type": "removed", "channels":["alpha"]}`) |
| 1791 | assert.NoError(t, err, "Error updating doc") |
| 1792 | _, err = updateTestDoc(rt, "doc_removed", revid, `{"type": "removed"}`) |
| 1793 | assert.NoError(t, err, "Error updating doc") |
| 1794 | |
| 1795 | // No access (no channels) |
| 1796 | _, err = updateTestDoc(rt, "doc_no_channels", "", `{"type": "no_channels", "channels":["gamma"]}`) |
| 1797 | assert.NoError(t, err, "Error updating doc") |
| 1798 | |
| 1799 | // No access (other channels) |
| 1800 | _, err = updateTestDoc(rt, "doc_no_access", "", `{"type": "no_access", "channels":["gamma"]}`) |
| 1801 | assert.NoError(t, err, "Error updating doc") |
| 1802 | |
| 1803 | // Removal, pruned from rev tree |
| 1804 | var prunedRevId string |
| 1805 | prunedRevId, err = updateTestDoc(rt, "doc_pruned", "", `{"type": "pruned", "channels":["alpha"]}`) |
| 1806 | assert.NoError(t, err, "Error updating doc") |
| 1807 | // Generate more revs than revs_limit (3) |
| 1808 | revid = prunedRevId |
| 1809 | for i := 0; i < 5; i++ { |
| 1810 | docVersion := rt.UpdateDoc("doc_pruned", db.DocVersion{RevTreeID: revid}, `{"type": "pruned", "channels":["gamma"]}`) |
| 1811 | revid = docVersion.RevTreeID |
| 1812 | } |
| 1813 | |
| 1814 | // Doc w/ attachment |
| 1815 | revid, err = updateTestDoc(rt, "doc_attachment", "", `{"type": "attachments", "channels":["alpha"]}`) |
nothing calls this directly
no test coverage detected