Skip to content

Commit b3b1a44

Browse files
committed
Fix unit test failures
1 parent 2904336 commit b3b1a44

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

src/xitdb/array_list.clj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@
3131

3232
clojure.lang.Sequential ;; Add this to mark as sequential
3333

34+
clojure.lang.Associative
35+
(assoc [this k v]
36+
(assoc (common/-materialize-shallow this) k v))
37+
38+
(containsKey [this k]
39+
(and (integer? k) (>= k 0) (< k (.count ral))))
40+
41+
(entryAt [this k]
42+
(when (.containsKey this k)
43+
(clojure.lang.MapEntry. k (.valAt this k))))
44+
3445
clojure.lang.IPersistentVector
3546
(assocN [this i val]
3647
(assoc (common/-materialize-shallow this) i val))

src/xitdb/util/conversion.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@
227227
(let [v-cursor (.appendCursor write-array)]
228228
(set->WriteCursor! v-cursor v))
229229

230-
(validation/vector-or-chunked? v)
230+
(or (validation/vector-or-chunked? v)
231+
(instance? java.util.List v))
231232
(let [v-cursor (.appendCursor write-array)]
232233
(coll->ArrayListCursor! v-cursor v))
233234

test/xitdb/branch_features_test.clj

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@
2727
(swap! db assoc :version 4)
2828

2929
;; Current state should be version 4
30-
(is (= {:version 4} @db))
30+
(is (= {:version 4} (tu/materialize @db)))
3131

3232
;; Access historical versions (0-indexed)
33-
(is (= {:version 1} (xdb/deref-at db 0)))
34-
(is (= {:version 2} (xdb/deref-at db 1)))
35-
(is (= {:version 3} (xdb/deref-at db 2)))
36-
(is (= {:version 4} (xdb/deref-at db 3)))
33+
(is (= {:version 1} (tu/materialize (xdb/deref-at db 0))))
34+
(is (= {:version 2} (tu/materialize (xdb/deref-at db 1))))
35+
(is (= {:version 3} (tu/materialize (xdb/deref-at db 2))))
36+
(is (= {:version 4} (tu/materialize (xdb/deref-at db 3))))
3737

3838
;; Using -1 should return the latest version
39-
(is (= {:version 4} (xdb/deref-at db -1))))))
39+
(is (= {:version 4} (tu/materialize (xdb/deref-at db -1)))))))
4040

4141
(deftest deref-at-complex-data-test
4242
(testing "deref-at works with complex nested data"
@@ -47,7 +47,7 @@
4747
(swap! db assoc :metadata {:count 2})
4848

4949
;; Check historical versions
50-
(is (= {:users []} (xdb/deref-at db 0)))
50+
(is (= {:users []} (tu/materialize (xdb/deref-at db 0))))
5151
(is (= {:users [{:name "Alice"}]} (tu/materialize (xdb/deref-at db 1))))
5252
(is (= {:users [{:name "Alice"} {:name "Bob"}]}
5353
(tu/materialize (xdb/deref-at db 2))))
@@ -61,9 +61,9 @@
6161
(swap! db conj 2)
6262
(swap! db conj 3)
6363

64-
(is (= [1] (xdb/deref-at db 0)))
65-
(is (= [1 2] (xdb/deref-at db 1)))
66-
(is (= [1 2 3] (xdb/deref-at db 2))))))
64+
(is (= [1] (tu/materialize (xdb/deref-at db 0))))
65+
(is (= [1 2] (tu/materialize (xdb/deref-at db 1))))
66+
(is (= [1 2 3] (tu/materialize (xdb/deref-at db 2)))))))
6767

6868
(deftest history-index-test
6969
(testing "history-index returns the current transaction count"
@@ -407,15 +407,15 @@
407407
(is (nil? (get (xdb/deref-at db 2) :value)))
408408
(is (= 2 (get (xdb/deref-at db 3) :value))))))
409409

410-
(deftest reset-preserves-slot-efficiency-test
411-
(testing "reset! with ISlot values uses slot directly"
410+
(deftest reset-preserves-data-integrity-test
411+
(testing "reset! with ISlot values from another database preserves data integrity"
412412
(with-open [db1 (xdb/xit-db :memory)
413413
db2 (xdb/xit-db :memory)]
414414
;; Create large nested data
415415
(reset! db1 {:data (vec (range 100))
416416
:nested {:more (vec (range 50))}})
417417

418-
;; Reset db2 with the value (should use slot efficiently)
418+
;; Reset db2 with the value (materializes for cross-database safety)
419419
(reset! db2 @db1)
420420

421421
;; Verify data integrity

0 commit comments

Comments
 (0)