@@ -762,6 +762,117 @@ function tests.test_commit_hook()
762762 print (" PASS: test_commit_hook" )
763763end
764764
765+ function tests .test_delete_column_family ()
766+ local path = " ./test_db_delete_cf"
767+ cleanup_db (path )
768+
769+ local db = tidesdb .TidesDB .open (path )
770+ db :create_column_family (" test_cf" )
771+ local cf = db :get_column_family (" test_cf" )
772+
773+ -- Insert data
774+ local txn = db :begin_txn ()
775+ txn :put (cf , " key1" , " value1" )
776+ txn :commit ()
777+ txn :free ()
778+
779+ -- Delete column family by pointer
780+ db :delete_column_family (cf )
781+
782+ -- Verify column family no longer exists
783+ local err = assert_error (function ()
784+ db :get_column_family (" test_cf" )
785+ end , " test_cf should not exist after delete" )
786+
787+ db :close ()
788+ cleanup_db (path )
789+ print (" PASS: test_delete_column_family" )
790+ end
791+
792+ function tests .test_iterator_seek ()
793+ local path = " ./test_db_iter_seek"
794+ cleanup_db (path )
795+
796+ local db = tidesdb .TidesDB .open (path )
797+ db :create_column_family (" test_cf" )
798+ local cf = db :get_column_family (" test_cf" )
799+
800+ -- Insert ordered data
801+ local txn = db :begin_txn ()
802+ txn :put (cf , " key:0001" , " val1" )
803+ txn :put (cf , " key:0002" , " val2" )
804+ txn :put (cf , " key:0003" , " val3" )
805+ txn :put (cf , " key:0004" , " val4" )
806+ txn :put (cf , " key:0005" , " val5" )
807+ txn :commit ()
808+ txn :free ()
809+
810+ -- Test seek to specific key
811+ local read_txn = db :begin_txn ()
812+ local iter = read_txn :new_iterator (cf )
813+
814+ iter :seek (" key:0003" )
815+ assert_true (iter :valid (), " iterator should be valid after seek" )
816+ assert_eq (iter :key (), " key:0003" , " seek should find exact key" )
817+
818+ -- Test seek_for_prev
819+ iter :seek_for_prev (" key:0004" )
820+ assert_true (iter :valid (), " iterator should be valid after seek_for_prev" )
821+ assert_eq (iter :key (), " key:0004" , " seek_for_prev should find exact key" )
822+
823+ -- Test seek to non-existent key (should find next key >= target)
824+ iter :seek (" key:0002x" )
825+ assert_true (iter :valid (), " iterator should be valid after seek to non-existent key" )
826+ assert_eq (iter :key (), " key:0003" , " seek should find next key >= target" )
827+
828+ iter :free ()
829+ read_txn :free ()
830+
831+ db :drop_column_family (" test_cf" )
832+ db :close ()
833+ cleanup_db (path )
834+ print (" PASS: test_iterator_seek" )
835+ end
836+
837+ function tests .test_multi_cf_transaction ()
838+ local path = " ./test_db_multi_cf"
839+ cleanup_db (path )
840+
841+ local db = tidesdb .TidesDB .open (path )
842+ db :create_column_family (" cf_a" )
843+ db :create_column_family (" cf_b" )
844+ local cf_a = db :get_column_family (" cf_a" )
845+ local cf_b = db :get_column_family (" cf_b" )
846+
847+ -- Atomic transaction across two column families
848+ local txn = db :begin_txn ()
849+ txn :put (cf_a , " user:1" , " Alice" )
850+ txn :put (cf_b , " order:1" , " user:1|item:A" )
851+ txn :commit ()
852+ txn :free ()
853+
854+ -- Verify both CFs have data
855+ local read_txn = db :begin_txn ()
856+ local user = read_txn :get (cf_a , " user:1" )
857+ local order = read_txn :get (cf_b , " order:1" )
858+ assert_eq (user , " Alice" , " cf_a should have user data" )
859+ assert_eq (order , " user:1|item:A" , " cf_b should have order data" )
860+ read_txn :free ()
861+
862+ -- Verify independence: data in cf_a is not in cf_b
863+ local verify_txn = db :begin_txn ()
864+ local err = assert_error (function ()
865+ verify_txn :get (cf_b , " user:1" )
866+ end , " user:1 should not exist in cf_b" )
867+ verify_txn :free ()
868+
869+ db :drop_column_family (" cf_a" )
870+ db :drop_column_family (" cf_b" )
871+ db :close ()
872+ cleanup_db (path )
873+ print (" PASS: test_multi_cf_transaction" )
874+ end
875+
765876function tests .test_max_memory_usage ()
766877 local path = " ./test_db_max_mem"
767878 cleanup_db (path )
0 commit comments