(t *testing.T)
| 2667 | } |
| 2668 | |
| 2669 | func TestChannelHistoryLegacyDoc(t *testing.T) { |
| 2670 | defer db.SuspendSequenceBatching()() |
| 2671 | |
| 2672 | rt := NewRestTester(t, &RestTesterConfig{SyncFn: channels.DocChannelsSyncFunction}) |
| 2673 | defer rt.Close() |
| 2674 | |
| 2675 | docData := ` |
| 2676 | { |
| 2677 | "channels": [ |
| 2678 | "test" |
| 2679 | ], |
| 2680 | "_sync": { |
| 2681 | "rev": "1-08267a64bf0e3963bab7dece1ea0887a", |
| 2682 | "sequence": 1, |
| 2683 | "recent_sequences": [ |
| 2684 | 1 |
| 2685 | ], |
| 2686 | "history": { |
| 2687 | "revs": [ |
| 2688 | "1-08267a64bf0e3963bab7dece1ea0887a" |
| 2689 | ], |
| 2690 | "parents": [ |
| 2691 | -1 |
| 2692 | ], |
| 2693 | "channels": [ |
| 2694 | [ |
| 2695 | "test" |
| 2696 | ] |
| 2697 | ] |
| 2698 | }, |
| 2699 | "channels": { |
| 2700 | "test": null |
| 2701 | }, |
| 2702 | "cas": "", |
| 2703 | "value_crc32c": "", |
| 2704 | "time_saved": "2021-05-04T18:37:07.559778+01:00" |
| 2705 | } |
| 2706 | }` |
| 2707 | |
| 2708 | // Insert raw 'legacy' doc with no channel history info |
| 2709 | err := rt.GetSingleDataStore().Set("doc1", 0, nil, []byte(docData)) |
| 2710 | assert.NoError(t, err) |
| 2711 | |
| 2712 | var body db.Body |
| 2713 | |
| 2714 | // Get doc and ensure its available |
| 2715 | resp := rt.SendAdminRequest("GET", "/{{.keyspace}}/doc1", "") |
| 2716 | RequireStatus(t, resp, http.StatusOK) |
| 2717 | |
| 2718 | // Remove doc from channel and ensure that channel history is built correctly with current end sequence and |
| 2719 | // setting start sequence |
| 2720 | resp = rt.SendAdminRequest("PUT", "/{{.keyspace}}/doc1?rev=1-08267a64bf0e3963bab7dece1ea0887a", `{"channels": []}`) |
| 2721 | RequireStatus(t, resp, http.StatusCreated) |
| 2722 | err = json.Unmarshal(resp.BodyBytes(), &body) |
| 2723 | assert.NoError(t, err) |
| 2724 | collection, ctx := rt.GetSingleTestDatabaseCollection() |
| 2725 | syncData, err := collection.GetDocSyncData(ctx, "doc1") |
| 2726 | assert.NoError(t, err) |
nothing calls this directly
no test coverage detected