2323 assert .True (t , cfg .API .Enabled , "API should be enabled" )
2424 assert .Equal (t , "0.0.0.0:3000" , cfg .API .Config .Bind , "API bind should be parsed correctly" )
2525
26- // Test validation
27- warns , errs := cfg .Validate ()
28- assert .Empty (t , errs , "Should have no validation errors" )
29- assert .Empty (t , warns , "Should have no validation warnings" )
26+ // Test API config validation directly (not full config validation)
27+ warns , errs := cfg .API . Config . Validate ()
28+ assert .Empty (t , errs , "Should have no API validation errors" )
29+ assert .Empty (t , warns , "Should have no API validation warnings" )
3030}
3131
3232func TestAPIConfigNested (t * testing.T ) {
4646 assert .Equal (t , "" , cfg .API .Config .Bind , "API bind should be empty (nested structure not supported with inline)" )
4747
4848 // Test validation (should fail because bind is empty)
49- _ , errs := cfg .Validate ()
49+ _ , errs := cfg .API . Config . Validate ()
5050 assert .NotEmpty (t , errs , "Should have validation errors because nested config is ignored" )
51- assert .Contains (t , errs [0 ].Error (), "api: " , "Error should mention API validation " )
51+ assert .Contains (t , errs [0 ].Error (), "bind address must not be empty " , "Error should mention empty bind " )
5252}
5353
5454func TestAPIConfigDisabled (t * testing.T ) {
6767 assert .Equal (t , "localhost:8080" , cfg .API .Config .Bind , "API bind should still be parsed" )
6868
6969 // Test validation (should pass even when disabled)
70- warns , errs := cfg .Validate ()
71- assert .Empty (t , errs , "Should have no validation errors for disabled API" )
72- assert .Empty (t , warns , "Should have no validation warnings for disabled API" )
70+ warns , errs := cfg .API . Config . Validate ()
71+ assert .Empty (t , errs , "Should have no API validation errors for disabled API" )
72+ assert .Empty (t , warns , "Should have no API validation warnings for disabled API" )
7373}
7474
7575func TestAPIConfigInvalidBind (t * testing.T ) {
8888 assert .Equal (t , "invalid-address" , cfg .API .Config .Bind , "Invalid bind should be parsed" )
8989
9090 // Test validation (should fail)
91- _ , errs := cfg .Validate ()
91+ _ , errs := cfg .API . Config . Validate ()
9292 assert .NotEmpty (t , errs , "Should have validation errors for invalid bind" )
93- assert .Contains (t , errs [0 ].Error (), "api: " , "Error should mention API validation " )
93+ assert .Contains (t , errs [0 ].Error (), "invalid bind " , "Error should mention invalid bind " )
9494}
9595
9696func TestAPIConfigEmptyBind (t * testing.T ) {
@@ -109,20 +109,20 @@ api:
109109 assert .Equal (t , "" , cfg .API .Config .Bind , "Empty bind should be parsed" )
110110
111111 // Test validation (should fail)
112- _ , errs := cfg .Validate ()
112+ _ , errs := cfg .API . Config . Validate ()
113113 assert .NotEmpty (t , errs , "Should have validation errors for empty bind" )
114- assert .Contains (t , errs [0 ].Error (), "api: " , "Error should mention API validation " )
114+ assert .Contains (t , errs [0 ].Error (), "bind address must not be empty " , "Error should mention empty bind " )
115115}
116116
117117func TestAPIConfigDefaultSecurity (t * testing.T ) {
118118 // Test that default config uses localhost (not 0.0.0.0) for security
119119 cfg := DefaultConfig
120-
120+
121121 assert .False (t , cfg .API .Enabled , "API should be disabled by default" )
122122 assert .Equal (t , "localhost:8080" , cfg .API .Config .Bind , "Default API bind should use localhost for security" )
123-
123+
124124 // Test that API config itself is valid (even though full config may have other warnings)
125125 apiWarns , apiErrs := cfg .API .Config .Validate ()
126126 assert .Empty (t , apiErrs , "Default API config should have no validation errors" )
127127 assert .Empty (t , apiWarns , "Default API config should have no validation warnings" )
128- }
128+ }
0 commit comments