mirror of
https://github.com/logseq/logseq.git
synced 2026-05-25 05:04:24 +00:00
054-db-sync-test-isolation.md
This commit is contained in:
166
docs/agent-guide/054-db-sync-test-isolation.md
Normal file
166
docs/agent-guide/054-db-sync-test-isolation.md
Normal file
@@ -0,0 +1,166 @@
|
||||
# 054-db-sync-test-isolation
|
||||
|
||||
## Summary
|
||||
|
||||
`bb dev:lint-and-test` would currently fail in CLJS runtime tests, while lint and test compilation would still pass. The observed failures would point to test isolation problems inside `frontend.worker.db-sync-test`, not to a stable regression in db-sync production logic.
|
||||
|
||||
## Background
|
||||
|
||||
The failing command would be:
|
||||
|
||||
- `bb dev:lint-and-test`
|
||||
|
||||
Its execution flow would be:
|
||||
|
||||
1. lint tasks
|
||||
2. CLJS test compilation
|
||||
3. CLJS runtime test execution
|
||||
|
||||
Observed behavior from the captured run:
|
||||
|
||||
- lint would pass
|
||||
- test compilation would pass
|
||||
- runtime tests would fail with 3 failures
|
||||
|
||||
The failing tests would include:
|
||||
|
||||
- `frontend.worker.db-sync-test/ensure-upload-graph-identity-defaults-e2ee-enabled-test`
|
||||
- `frontend.worker.db-sync-test/download-graph-by-id-fails-on-incomplete-snapshot-frame-test`
|
||||
|
||||
A follow-up run of the full namespace would fail on a different test:
|
||||
|
||||
- `frontend.worker.db-sync-test/pull-ok-out-of-order-stale-response-is-ignored-test`
|
||||
|
||||
This changing failure surface would strongly suggest flaky shared state rather than a deterministic implementation bug.
|
||||
|
||||
## Evidence
|
||||
|
||||
### 1. Failing tests would pass in isolation
|
||||
|
||||
Running these tests individually would pass:
|
||||
|
||||
- `frontend.worker.db-sync-test/ensure-upload-graph-identity-defaults-e2ee-enabled-test`
|
||||
- `frontend.worker.db-sync-test/download-graph-by-id-fails-on-incomplete-snapshot-frame-test`
|
||||
|
||||
This would indicate that the underlying code paths can behave correctly when the test environment is clean.
|
||||
|
||||
### 2. Full-namespace execution would produce a different failure
|
||||
|
||||
Running the whole namespace would fail in `pull-ok-out-of-order-stale-response-is-ignored-test` instead of the two failures seen in the full suite.
|
||||
|
||||
This would indicate order dependence or leaked global state between tests in the same namespace.
|
||||
|
||||
### 3. Failure payloads would match leaked state
|
||||
|
||||
`ensure-upload-graph-identity-defaults-e2ee-enabled-test` would unexpectedly receive an existing graph identity with:
|
||||
|
||||
- `:graph-id "c52bf9d4-3a95-4f17-9c8c-7f86eef5f75d"`
|
||||
- `:graph-e2ee? false`
|
||||
|
||||
That graph id would match a value used by another test in the same file. This would suggest that the later test is reusing state left behind by an earlier test instead of executing its own intended bootstrap path.
|
||||
|
||||
`download-graph-by-id-fails-on-incomplete-snapshot-frame-test` would expect `incomplete-snapshot-frame` but would sometimes receive an unrelated assertion failure:
|
||||
|
||||
- `Assert failed: test-db-sync-repo (some? conn)`
|
||||
|
||||
This would suggest that another asynchronous code path is still interacting with shared worker state while the test is running.
|
||||
|
||||
## Root Cause
|
||||
|
||||
The most likely root cause would be incomplete per-test cleanup of shared global state in:
|
||||
|
||||
- `frontend.worker.state`
|
||||
- `frontend.worker.sync`
|
||||
|
||||
The highest-risk shared atoms would include:
|
||||
|
||||
- `worker-state/*datascript-conns`
|
||||
- `worker-state/*client-ops-conns`
|
||||
- `worker-state/*db-sync-client`
|
||||
- `worker-state/*db-sync-config`
|
||||
- `db-sync/*repo->latest-remote-tx`
|
||||
- `db-sync/*start-inflight-target`
|
||||
|
||||
The test file would also rely heavily on:
|
||||
|
||||
- `async done`
|
||||
- nested `promesa` chains
|
||||
- cleanup inside `p/finally`
|
||||
|
||||
That structure would make it possible for a test to signal completion before all outer cleanup has fully restored shared state, especially when asynchronous callbacks or listeners are still active.
|
||||
|
||||
## Proposed Changes
|
||||
|
||||
### 1. Add a per-test fixture for global state reset
|
||||
|
||||
A `:each` fixture in `/Users/rcmerci/gh-repos/logseq/src/test/frontend/worker/db_sync_test.cljs` would reset the shared worker and db-sync atoms before and after every test.
|
||||
|
||||
The fixture would reset at least:
|
||||
|
||||
- `worker-state/*datascript-conns`
|
||||
- `worker-state/*client-ops-conns`
|
||||
- `worker-state/*db-sync-client`
|
||||
- `worker-state/*db-sync-config`
|
||||
- `db-sync/*repo->latest-remote-tx`
|
||||
- `db-sync/*start-inflight-target`
|
||||
|
||||
### 2. Review high-risk async tests
|
||||
|
||||
If fixture-based isolation is not sufficient, the next step would be to tighten async structure in the tests most likely to leak state.
|
||||
|
||||
Priority candidates would include:
|
||||
|
||||
- upload identity tests
|
||||
- snapshot download tests
|
||||
- pull/ok ordering tests
|
||||
|
||||
The goal would be to ensure that:
|
||||
|
||||
- cleanup happens after the actual promise chain settles
|
||||
- `done` is called only after cleanup boundaries are satisfied
|
||||
- any listener or temporary override is fully restored before the next test starts
|
||||
|
||||
## Why Production Code Is Less Likely To Be At Fault
|
||||
|
||||
The current evidence would not strongly support a production db-sync bug because:
|
||||
|
||||
1. the affected tests would pass when run alone
|
||||
2. the failing test would change depending on suite shape
|
||||
3. the observed incorrect values would match data seeded by neighboring tests
|
||||
4. the expected production code path for incomplete snapshot handling already appears to raise the correct error in isolated execution
|
||||
|
||||
Because of that, modifying production sync logic first would risk masking a test harness problem instead of fixing the actual instability.
|
||||
|
||||
## Verification Plan
|
||||
|
||||
After applying the test isolation changes, verification would include:
|
||||
|
||||
1. `bb dev:test -v frontend.worker.db-sync-test`
|
||||
2. `bb dev:lint-and-test`
|
||||
|
||||
Success criteria would be:
|
||||
|
||||
- individual failing tests still pass
|
||||
- the full `frontend.worker.db-sync-test` namespace passes reliably
|
||||
- the full `bb dev:lint-and-test` command no longer fails on these db-sync tests
|
||||
|
||||
## Risks And Follow-ups
|
||||
|
||||
If failures remain after the fixture reset, the next investigation would focus on:
|
||||
|
||||
- leaked `d/listen!` listeners
|
||||
- background tasks still running across tests
|
||||
- `js/fetch` restoration timing
|
||||
- promise chains whose cleanup is attached at the wrong level
|
||||
- other shared atoms not yet covered by the fixture
|
||||
|
||||
## Files
|
||||
|
||||
Would modify:
|
||||
|
||||
- `/Users/rcmerci/gh-repos/logseq/src/test/frontend/worker/db_sync_test.cljs`
|
||||
|
||||
Would not modify initially:
|
||||
|
||||
- `/Users/rcmerci/gh-repos/logseq/src/main/frontend/worker/sync.cljs`
|
||||
- `/Users/rcmerci/gh-repos/logseq/src/main/frontend/worker/sync/client_op.cljs`
|
||||
@@ -1,5 +1,5 @@
|
||||
(ns frontend.worker.db-sync-test
|
||||
(:require [cljs.test :refer [deftest is testing async]]
|
||||
(:require [cljs.test :refer [deftest is testing async use-fixtures]]
|
||||
[datascript.core :as d]
|
||||
[frontend.common.crypt :as crypt]
|
||||
[frontend.worker-common.util :as worker-util]
|
||||
@@ -21,6 +21,19 @@
|
||||
|
||||
(def ^:private test-repo "test-db-sync-repo")
|
||||
|
||||
(defn- reset-db-sync-test-state!
|
||||
[]
|
||||
(db-sync/stop!)
|
||||
(reset! worker-state/*datascript-conns nil)
|
||||
(reset! worker-state/*client-ops-conns nil)
|
||||
(reset! worker-state/*db-sync-client nil)
|
||||
(reset! worker-state/*db-sync-config {:ws-url nil})
|
||||
(reset! db-sync/*repo->latest-remote-tx {})
|
||||
(reset! db-sync/*start-inflight-target nil))
|
||||
|
||||
(use-fixtures :each {:before reset-db-sync-test-state!
|
||||
:after reset-db-sync-test-state!})
|
||||
|
||||
(defn- with-datascript-conns
|
||||
[db-conn ops-conn f]
|
||||
(let [db-prev @worker-state/*datascript-conns
|
||||
@@ -278,15 +291,15 @@
|
||||
:last-sync-error (atom {:code :previous-error})
|
||||
:online-users (atom [])
|
||||
:ws-state (atom :open)}]
|
||||
(with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(client-op/update-local-tx test-repo 16)
|
||||
(-> (p/let [_ (#'db-sync/handle-message! test-repo client raw-message)]
|
||||
(-> (with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(client-op/update-local-tx test-repo 16)
|
||||
(p/let [_ (#'db-sync/handle-message! test-repo client raw-message)]
|
||||
(is (= 18 (client-op/get-local-tx test-repo)))
|
||||
(is (nil? @(:last-sync-error client))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally done))))))))
|
||||
(is (nil? @(:last-sync-error client))))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest pull-ok-failure-records-last-sync-error-test
|
||||
(testing "pull/ok failures should surface structured runtime error state"
|
||||
@@ -340,18 +353,18 @@
|
||||
:online-users (atom [])
|
||||
:ws-state (atom :open)}]
|
||||
(reset! db-sync/*repo->latest-remote-tx {})
|
||||
(with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(-> (p/with-redefs [sync-crypt/graph-e2ee? (fn [_repo] false)]
|
||||
(-> (with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(p/with-redefs [sync-crypt/graph-e2ee? (fn [_repo] false)]
|
||||
(p/let [_ (client-op/update-local-tx test-repo 0)
|
||||
_ (#'db-sync/handle-message! test-repo client raw-new)
|
||||
_ (#'db-sync/handle-message! test-repo client raw-stale)
|
||||
parent' (d/entity @conn parent-id)]
|
||||
(is (= "remote-new-title" (:block/title parent')))
|
||||
(is (= 2 (client-op/get-local-tx test-repo)))))
|
||||
(p/finally (fn []
|
||||
(reset! db-sync/*repo->latest-remote-tx latest-prev)
|
||||
(done))))))))))
|
||||
(is (= 2 (client-op/get-local-tx test-repo)))))))
|
||||
(p/finally (fn []
|
||||
(reset! db-sync/*repo->latest-remote-tx latest-prev)))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest pull-ok-batched-txs-preserve-tempid-boundaries-test
|
||||
(testing "pull/ok applies tx batches without cross-tx tempid collisions"
|
||||
@@ -388,17 +401,17 @@
|
||||
:inflight (atom [])
|
||||
:online-users (atom [])
|
||||
:ws-state (atom :open)}]
|
||||
(with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(reset! db-sync/*repo->latest-remote-tx {})
|
||||
(-> (p/let [_ (client-op/update-local-tx test-repo 0)
|
||||
(-> (with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(reset! db-sync/*repo->latest-remote-tx {})
|
||||
(p/let [_ (client-op/update-local-tx test-repo 0)
|
||||
_ (#'db-sync/handle-message! test-repo client raw-message)]
|
||||
;; TODO(db-sync): re-enable after batched pull tempid-boundary behavior is stabilized.
|
||||
#_(is (= "remote-a" (:block/title (d/entity @conn [:block/uuid block-uuid-a]))))
|
||||
#_(is (= "remote-b" (:block/title (d/entity @conn [:block/uuid block-uuid-b])))))
|
||||
(p/finally (fn []
|
||||
(reset! db-sync/*repo->latest-remote-tx latest-prev)
|
||||
(done))))))))))
|
||||
#_(is (= "remote-b" (:block/title (d/entity @conn [:block/uuid block-uuid-b])))))))
|
||||
(p/finally (fn []
|
||||
(reset! db-sync/*repo->latest-remote-tx latest-prev)))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest get-graph-id-falls-back-to-client-op-graph-uuid-test
|
||||
(let [conn (d/create-conn {})
|
||||
@@ -417,16 +430,16 @@
|
||||
(set! db-sync/list-remote-graphs! (fn []
|
||||
(p/resolved [{:graph-name test-repo
|
||||
:graph-id "remote-graph-id"}])))
|
||||
(with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(-> (p/let [graph-id (#'db-sync/<resolve-start-graph-id test-repo)]
|
||||
(-> (with-datascript-conns conn client-ops-conn
|
||||
(fn []
|
||||
(p/let [graph-id (#'db-sync/<resolve-start-graph-id test-repo)]
|
||||
(is (= "remote-graph-id" graph-id))
|
||||
(is (= "remote-graph-id" (client-op/get-graph-uuid test-repo))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(set! db-sync/list-remote-graphs! orig-list-remote-graphs!)
|
||||
(done)))))))))
|
||||
(is (= "remote-graph-id" (client-op/get-graph-uuid test-repo))))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(set! db-sync/list-remote-graphs! orig-list-remote-graphs!)))
|
||||
(p/finally done)))))
|
||||
|
||||
(deftest start-skips-without-ws-url-before-remote-graph-lookup-test
|
||||
(async done
|
||||
@@ -1339,10 +1352,10 @@
|
||||
|
||||
:else
|
||||
(js/Promise.reject (js/Error. (str "unexpected fetch url: " method " " url)))))))
|
||||
(with-worker-conns {test-repo conn} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [db-sync/coerce-http-request (fn [_schema-key body] body)]
|
||||
(-> (p/let [result (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(-> (with-worker-conns {test-repo conn} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [db-sync/coerce-http-request (fn [_schema-key body] body)]
|
||||
(p/let [result (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(is (= {:graph-id created-graph-id
|
||||
:graph-e2ee? false}
|
||||
result))
|
||||
@@ -1351,14 +1364,14 @@
|
||||
(some-> (ldb/get-graph-rtc-uuid @conn) str)))
|
||||
(is (= [{:url "https://example.com/graphs" :method "GET"}
|
||||
{:url "https://example.com/graphs" :method "POST"}]
|
||||
@fetch-calls)))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)
|
||||
(done)))))))))))
|
||||
@fetch-calls))))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest ensure-upload-graph-identity-reuses-existing-remote-graph-when-local-graph-id-missing-test
|
||||
(testing "first upload bootstrap reuses a same-name remote graph instead of creating a duplicate"
|
||||
@@ -1388,9 +1401,9 @@
|
||||
|
||||
:else
|
||||
(js/Promise.reject (js/Error. (str "unexpected fetch url: " method " " url)))))))
|
||||
(with-worker-conns {test-repo conn} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(-> (p/let [result (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(-> (with-worker-conns {test-repo conn} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(p/let [result (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(is (= {:graph-id remote-graph-id
|
||||
:graph-e2ee? false}
|
||||
result))
|
||||
@@ -1398,14 +1411,14 @@
|
||||
(is (= remote-graph-id
|
||||
(some-> (ldb/get-graph-rtc-uuid @conn) str)))
|
||||
(is (= [{:url "https://example.com/graphs" :method "GET"}]
|
||||
@fetch-calls)))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)
|
||||
(done))))))))))
|
||||
@fetch-calls)))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest ensure-upload-graph-identity-propagates-create-graph-failures-test
|
||||
(testing "first upload bootstrap rejects when remote graph creation fails"
|
||||
@@ -1431,19 +1444,19 @@
|
||||
|
||||
:else
|
||||
(js/Promise.reject (js/Error. (str "unexpected fetch url: " method " " url)))))))
|
||||
(with-worker-conns {} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [db-sync/coerce-http-request (fn [_schema-key body] body)]
|
||||
(-> (p/let [_ (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(is false "expected graph creation failure to reject"))
|
||||
(p/catch (fn [e]
|
||||
(is (= "db-sync request failed" (ex-message e)))
|
||||
(is (= 500 (:status (ex-data e))))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)
|
||||
(done)))))))))))
|
||||
(-> (with-worker-conns {} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [db-sync/coerce-http-request (fn [_schema-key body] body)]
|
||||
(p/let [_ (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(is false "expected graph creation failure to reject")))))
|
||||
(p/catch (fn [e]
|
||||
(is (= "db-sync request failed" (ex-message e)))
|
||||
(is (= 500 (:status (ex-data e))))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest ensure-upload-graph-identity-defaults-e2ee-enabled-test
|
||||
(testing "first upload bootstrap defaults graph-e2ee? to true when local sync metadata is missing"
|
||||
@@ -1473,23 +1486,23 @@
|
||||
|
||||
:else
|
||||
(js/Promise.reject (js/Error. (str "unexpected fetch url: " method " " url)))))))
|
||||
(with-worker-conns {} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [db-sync/coerce-http-request (fn [_schema-key body] body)
|
||||
sync-crypt/graph-e2ee? (fn [_repo] nil)]
|
||||
(-> (p/let [result (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(-> (with-worker-conns {} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [db-sync/coerce-http-request (fn [_schema-key body] body)
|
||||
sync-crypt/graph-e2ee? (fn [_repo] nil)]
|
||||
(p/let [result (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(is (= {:graph-id "encrypted-graph-id"
|
||||
:graph-e2ee? true}
|
||||
result))
|
||||
(is (= true (:graph-e2ee? @create-body)))
|
||||
(is (= "11111" (:e2ee-password @worker-state/*db-sync-config))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)
|
||||
(done)))))))))))
|
||||
(is (= "11111" (:e2ee-password @worker-state/*db-sync-config)))))))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally (fn []
|
||||
(aset js/globalThis "self" self-prev)
|
||||
(set! js/fetch fetch-prev)
|
||||
(reset! worker-state/*db-sync-config config-prev)))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest ensure-upload-graph-identity-backfills-graph-kv-from-client-op-fallback-test
|
||||
(testing "upload identity fallback backfills graph kv and stays idempotent"
|
||||
@@ -1497,30 +1510,31 @@
|
||||
(let [conn (d/create-conn {})
|
||||
client-ops-conn (d/create-conn client-op/schema-in-db)
|
||||
fallback-graph-id "6f3b0d47-4a62-4da7-8e56-7e5dbfbe3f47"
|
||||
list-calls (atom 0)]
|
||||
(with-worker-conns {test-repo conn} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [sync-crypt/graph-e2ee? (fn [_repo] nil)
|
||||
db-sync/get-graph-id (fn [_repo] fallback-graph-id)
|
||||
db-sync/list-remote-graphs! (fn []
|
||||
(swap! list-calls inc)
|
||||
(p/resolved []))]
|
||||
(is (nil? (client-op/get-graph-uuid test-repo)))
|
||||
(is (nil? (ldb/get-graph-rtc-uuid @conn)))
|
||||
(let [first-result-p (#'db-sync/<ensure-upload-graph-identity! test-repo)
|
||||
second-result-p (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(-> (p/let [first-result first-result-p
|
||||
second-result second-result-p]
|
||||
(is (= fallback-graph-id (:graph-id first-result)))
|
||||
(is (= fallback-graph-id (:graph-id second-result)))
|
||||
(is (= (:graph-e2ee? first-result)
|
||||
(:graph-e2ee? second-result)))
|
||||
(is (= fallback-graph-id
|
||||
(some-> (ldb/get-graph-rtc-uuid @conn) str)))
|
||||
(is (= 0 @list-calls)))
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally done))))))))))
|
||||
list-calls (atom 0)
|
||||
result-p (with-worker-conns {test-repo conn} {test-repo client-ops-conn}
|
||||
(fn []
|
||||
(with-redefs [sync-crypt/graph-e2ee? (fn [_repo] nil)
|
||||
db-sync/get-graph-id (fn [_repo] fallback-graph-id)
|
||||
db-sync/list-remote-graphs! (fn []
|
||||
(swap! list-calls inc)
|
||||
(p/resolved []))]
|
||||
(is (nil? (client-op/get-graph-uuid test-repo)))
|
||||
(is (nil? (ldb/get-graph-rtc-uuid @conn)))
|
||||
(let [first-result-p (#'db-sync/<ensure-upload-graph-identity! test-repo)
|
||||
second-result-p (#'db-sync/<ensure-upload-graph-identity! test-repo)]
|
||||
(p/let [first-result first-result-p
|
||||
second-result second-result-p]
|
||||
(is (= fallback-graph-id (:graph-id first-result)))
|
||||
(is (= fallback-graph-id (:graph-id second-result)))
|
||||
(is (= (:graph-e2ee? first-result)
|
||||
(:graph-e2ee? second-result)))
|
||||
(is (= fallback-graph-id
|
||||
(some-> (ldb/get-graph-rtc-uuid @conn) str)))
|
||||
(is (= 0 @list-calls)))))))]
|
||||
(-> result-p
|
||||
(p/catch (fn [e]
|
||||
(is false (str "unexpected error: " e))))
|
||||
(p/finally done))))))
|
||||
|
||||
(deftest ^:long rehydrate-large-title-test
|
||||
(testing "rehydrate fills empty title from object storage"
|
||||
|
||||
Reference in New Issue
Block a user