@@ -22,6 +22,7 @@ describe("Configuration", function()
2222 expect (config .defaults ).to_have_key (" auto_start" )
2323 expect (config .defaults ).to_have_key (" log_level" )
2424 expect (config .defaults ).to_have_key (" track_selection" )
25+ expect (config .defaults ).to_have_key (" models" )
2526 end )
2627
2728 it (" should validate valid configuration" , function ()
@@ -38,6 +39,9 @@ describe("Configuration", function()
3839 vertical_split = true ,
3940 open_in_current_tab = true ,
4041 },
42+ models = {
43+ { name = " Test Model" , value = " test-model" },
44+ },
4145 }
4246
4347 local success = config .validate (valid_config )
@@ -74,6 +78,54 @@ describe("Configuration", function()
7478 expect (success ).to_be_false ()
7579 end )
7680
81+ it (" should reject invalid models configuration" , function ()
82+ local invalid_config = {
83+ port_range = { min = 10000 , max = 65535 },
84+ auto_start = true ,
85+ log_level = " debug" ,
86+ track_selection = false ,
87+ visual_demotion_delay_ms = 50 ,
88+ diff_opts = {
89+ auto_close_on_accept = true ,
90+ show_diff_stats = true ,
91+ vertical_split = true ,
92+ open_in_current_tab = true ,
93+ },
94+ models = {}, -- Empty models array should be rejected
95+ }
96+
97+ local success , _ = pcall (function ()
98+ config .validate (invalid_config )
99+ end )
100+
101+ expect (success ).to_be_false ()
102+ end )
103+
104+ it (" should reject models with invalid structure" , function ()
105+ local invalid_config = {
106+ port_range = { min = 10000 , max = 65535 },
107+ auto_start = true ,
108+ log_level = " debug" ,
109+ track_selection = false ,
110+ visual_demotion_delay_ms = 50 ,
111+ diff_opts = {
112+ auto_close_on_accept = true ,
113+ show_diff_stats = true ,
114+ vertical_split = true ,
115+ open_in_current_tab = true ,
116+ },
117+ models = {
118+ { name = " Test Model" }, -- Missing value field
119+ },
120+ }
121+
122+ local success , _ = pcall (function ()
123+ config .validate (invalid_config )
124+ end )
125+
126+ expect (success ).to_be_false ()
127+ end )
128+
77129 it (" should merge user config with defaults" , function ()
78130 local user_config = {
79131 auto_start = true ,
@@ -86,6 +138,7 @@ describe("Configuration", function()
86138 expect (merged_config .log_level ).to_be (" debug" )
87139 expect (merged_config .port_range .min ).to_be (config .defaults .port_range .min )
88140 expect (merged_config .track_selection ).to_be (config .defaults .track_selection )
141+ expect (merged_config .models ).to_be_table ()
89142 end )
90143
91144 teardown ()
0 commit comments