@@ -213,7 +213,7 @@ func assertCMAB(t *testing.T, cmab config.CMABConfig) {
213213}
214214
215215func TestCMABEnvDebug (t * testing.T ) {
216- _ = os .Setenv ("OPTIMIZELY_CMAB " , `{
216+ _ = os .Setenv ("OPTIMIZELY_CLIENT_CMAB " , `{
217217 "requestTimeout": "15s",
218218 "cache": {
219219 "default": "redis",
@@ -245,72 +245,72 @@ func TestCMABEnvDebug(t *testing.T) {
245245
246246 // Debug: Print the parsed config
247247 fmt .Println ("Parsed CMAB config from JSON env var:" )
248- fmt .Printf (" RequestTimeout: %v\n " , conf .CMAB .RequestTimeout )
249- fmt .Printf (" Cache: %+v\n " , conf .CMAB .Cache )
250- fmt .Printf (" RetryConfig: %+v\n " , conf .CMAB .RetryConfig )
248+ fmt .Printf (" RequestTimeout: %v\n " , conf .Client . CMAB .RequestTimeout )
249+ fmt .Printf (" Cache: %+v\n " , conf .Client . CMAB .Cache )
250+ fmt .Printf (" RetryConfig: %+v\n " , conf .Client . CMAB .RetryConfig )
251251
252252 // Call assertCMAB
253- assertCMAB (t , conf .CMAB )
253+ assertCMAB (t , conf .Client . CMAB )
254254}
255255
256256func TestCMABPartialConfig (t * testing.T ) {
257257 // Clean any existing environment variables
258- os .Unsetenv ("OPTIMIZELY_CMAB " )
259- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE " )
260- os .Unsetenv ("OPTIMIZELY_CMAB_RETRYCONFIG " )
258+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB " )
259+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE " )
260+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_RETRYCONFIG " )
261261
262262 // Set partial configuration through CMAB_CACHE and CMAB_RETRYCONFIG
263263 // Note: Cache is now a service-based map config
264- _ = os .Setenv ("OPTIMIZELY_CMAB_CACHE " , `{"default": "redis", "services": {"redis": {"host": "localhost:6379", "database": 0}}}` )
265- _ = os .Setenv ("OPTIMIZELY_CMAB_RETRYCONFIG " , `{"maxRetries": 10}` )
264+ _ = os .Setenv ("OPTIMIZELY_CLIENT_CMAB_CACHE " , `{"default": "redis", "services": {"redis": {"host": "localhost:6379", "database": 0}}}` )
265+ _ = os .Setenv ("OPTIMIZELY_CLIENT_CMAB_RETRYCONFIG " , `{"maxRetries": 10}` )
266266
267267 // Load config
268268 v := viper .New ()
269269 assert .NoError (t , initConfig (v ))
270270 conf := loadConfig (v )
271271
272272 // Cache assertions (cache is now map[string]interface{})
273- assert .NotNil (t , conf .CMAB .Cache )
274- if defaultCache , ok := conf .CMAB .Cache ["default" ].(string ); ok {
273+ assert .NotNil (t , conf .Client . CMAB .Cache )
274+ if defaultCache , ok := conf .Client . CMAB .Cache ["default" ].(string ); ok {
275275 assert .Equal (t , "redis" , defaultCache )
276276 }
277277
278278 // RetryConfig assertions
279- assert .Equal (t , 10 , conf .CMAB .RetryConfig .MaxRetries )
279+ assert .Equal (t , 10 , conf .Client . CMAB .RetryConfig .MaxRetries )
280280
281281 // Clean up
282- os .Unsetenv ("OPTIMIZELY_CMAB " )
283- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE " )
284- os .Unsetenv ("OPTIMIZELY_CMAB_RETRYCONFIG " )
282+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB " )
283+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE " )
284+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_RETRYCONFIG " )
285285}
286286
287287func TestCMABRetryConfigAllFields (t * testing.T ) {
288288 // Clean any existing environment variables
289- os .Unsetenv ("OPTIMIZELY_CMAB " )
290- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE " )
291- os .Unsetenv ("OPTIMIZELY_CMAB_RETRYCONFIG " )
289+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB " )
290+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE " )
291+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_RETRYCONFIG " )
292292
293293 // Set all retry config fields via CMAB_RETRYCONFIG to cover lines 154-165
294- _ = os .Setenv ("OPTIMIZELY_CMAB_RETRYCONFIG " , `{
294+ _ = os .Setenv ("OPTIMIZELY_CLIENT_CMAB_RETRYCONFIG " , `{
295295 "maxRetries": 5,
296296 "initialBackoff": "500ms",
297297 "maxBackoff": "45s",
298298 "backoffMultiplier": 2.5
299299 }` )
300300
301301 defer func () {
302- os .Unsetenv ("OPTIMIZELY_CMAB_RETRYCONFIG " )
302+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_RETRYCONFIG " )
303303 }()
304304
305305 v := viper .New ()
306306 assert .NoError (t , initConfig (v ))
307307 conf := loadConfig (v )
308308
309309 // Verify all retry config fields were parsed correctly
310- assert .Equal (t , 5 , conf .CMAB .RetryConfig .MaxRetries )
311- assert .Equal (t , 500 * time .Millisecond , conf .CMAB .RetryConfig .InitialBackoff )
312- assert .Equal (t , 45 * time .Second , conf .CMAB .RetryConfig .MaxBackoff )
313- assert .Equal (t , 2.5 , conf .CMAB .RetryConfig .BackoffMultiplier )
310+ assert .Equal (t , 5 , conf .Client . CMAB .RetryConfig .MaxRetries )
311+ assert .Equal (t , 500 * time .Millisecond , conf .Client . CMAB .RetryConfig .InitialBackoff )
312+ assert .Equal (t , 45 * time .Second , conf .Client . CMAB .RetryConfig .MaxBackoff )
313+ assert .Equal (t , 2.5 , conf .Client . CMAB .RetryConfig .BackoffMultiplier )
314314}
315315
316316func TestCMABRetryConfigIntMaxRetries (t * testing.T ) {
@@ -320,12 +320,12 @@ func TestCMABRetryConfigIntMaxRetries(t *testing.T) {
320320 assert .NoError (t , initConfig (v ))
321321
322322 // Set via viper directly to ensure it's an int, not float64
323- v .Set ("cmab.retryConfig.maxRetries" , 7 )
323+ v .Set ("client. cmab.retryConfig.maxRetries" , 7 )
324324
325325 conf := loadConfig (v )
326326
327327 // Verify maxRetries was parsed as int
328- assert .Equal (t , 7 , conf .CMAB .RetryConfig .MaxRetries )
328+ assert .Equal (t , 7 , conf .Client . CMAB .RetryConfig .MaxRetries )
329329}
330330
331331func TestViperYaml (t * testing.T ) {
@@ -542,7 +542,7 @@ func TestViperEnv(t *testing.T) {
542542 _ = os .Setenv ("OPTIMIZELY_WEBHOOK_PROJECTS_20000_SDKKEYS" , "xxx,yyy,zzz" )
543543 _ = os .Setenv ("OPTIMIZELY_WEBHOOK_PROJECTS_20000_SKIPSIGNATURECHECK" , "false" )
544544
545- _ = os .Setenv ("OPTIMIZELY_CMAB " , `{
545+ _ = os .Setenv ("OPTIMIZELY_CLIENT_CMAB " , `{
546546 "requestTimeout": "15s",
547547 "cache": {
548548 "default": "redis",
@@ -577,7 +577,7 @@ func TestViperEnv(t *testing.T) {
577577 assertAPI (t , actual .API )
578578 //assertWebhook(t, actual.Webhook) // Maps don't appear to be supported
579579 assertRuntime (t , actual .Runtime )
580- assertCMAB (t , actual .CMAB )
580+ assertCMAB (t , actual .Client . CMAB )
581581}
582582
583583func TestLoggingWithIncludeSdkKey (t * testing.T ) {
@@ -681,27 +681,27 @@ func Test_initTracing(t *testing.T) {
681681
682682func TestCMABComplexJSON (t * testing.T ) {
683683 // Clean any existing environment variables for CMAB
684- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE_TYPE " )
685- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE_SIZE " )
686- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE_TTL " )
687- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE_REDIS_HOST " )
688- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE_REDIS_PASSWORD " )
689- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE_REDIS_DATABASE " )
684+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE_TYPE " )
685+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE_SIZE " )
686+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE_TTL " )
687+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE_REDIS_HOST " )
688+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE_REDIS_PASSWORD " )
689+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE_REDIS_DATABASE " )
690690
691691 // Set complex JSON environment variable for CMAB cache (using new service-based format)
692- _ = os .Setenv ("OPTIMIZELY_CMAB_CACHE " , `{"default":"redis","services":{"redis":{"host":"localhost:6379","database":0,"timeout":"3h"}}}` )
692+ _ = os .Setenv ("OPTIMIZELY_CLIENT_CMAB_CACHE " , `{"default":"redis","services":{"redis":{"host":"localhost:6379","database":0,"timeout":"3h"}}}` )
693693
694694 defer func () {
695695 // Clean up
696- os .Unsetenv ("OPTIMIZELY_CMAB_CACHE " )
696+ os .Unsetenv ("OPTIMIZELY_CLIENT_CMAB_CACHE " )
697697 }()
698698
699699 v := viper .New ()
700700 assert .NoError (t , initConfig (v ))
701701 actual := loadConfig (v )
702702
703703 // Test cache settings from JSON environment variable (cache is now map[string]interface{})
704- cache := actual .CMAB .Cache
704+ cache := actual .Client . CMAB .Cache
705705 assert .NotNil (t , cache )
706706 if defaultCache , ok := cache ["default" ].(string ); ok {
707707 assert .Equal (t , "redis" , defaultCache )
0 commit comments