@@ -762,6 +762,43 @@ function tests.test_commit_hook()
762762 print (" PASS: test_commit_hook" )
763763end
764764
765+ function tests .test_max_memory_usage ()
766+ local path = " ./test_db_max_mem"
767+ cleanup_db (path )
768+
769+ -- Test default config includes max_memory_usage
770+ local default_cfg = tidesdb .default_config ()
771+ assert_true (default_cfg .max_memory_usage ~= nil , " max_memory_usage should exist in default config" )
772+
773+ -- Test opening database with default max_memory_usage (0 = unlimited)
774+ local db1 = tidesdb .TidesDB .open (path )
775+ assert_true (db1 ~= nil , " database should open with default max_memory_usage" )
776+ db1 :close ()
777+ cleanup_db (path )
778+
779+ -- Test opening database with custom max_memory_usage
780+ local db2 = tidesdb .TidesDB .open (path , {
781+ max_memory_usage = 512 * 1024 * 1024 -- 512 MB
782+ })
783+ assert_true (db2 ~= nil , " database should open with custom max_memory_usage" )
784+ db2 :close ()
785+ cleanup_db (path )
786+
787+ -- Test with TidesDB.new() constructor
788+ local config = {
789+ db_path = path ,
790+ num_flush_threads = 2 ,
791+ num_compaction_threads = 2 ,
792+ max_memory_usage = 256 * 1024 * 1024 -- 256 MB
793+ }
794+ local db3 = tidesdb .TidesDB .new (config )
795+ assert_true (db3 ~= nil , " database should be created with TidesDB.new() and max_memory_usage" )
796+ db3 :close ()
797+
798+ cleanup_db (path )
799+ print (" PASS: test_max_memory_usage" )
800+ end
801+
765802-- Run all tests
766803local function run_tests ()
767804 print (" Running TidesDB Lua tests..." )
0 commit comments