|
1 | 1 | /****************************************************************************
|
2 |
| - * Copyright 2021, Optimizely, Inc. and contributors * |
| 2 | + * Copyright 2021-2025, Optimizely, Inc. and contributors * |
3 | 3 | * *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); *
|
5 | 5 | * you may not use this file except in compliance with the License. *
|
@@ -68,3 +68,47 @@ func TestTranslateOptionsInvalidCases(t *testing.T) {
|
68 | 68 | assert.Equal(t, fmt.Errorf("invalid option: %v", options[0]), err)
|
69 | 69 | assert.Len(t, translatedOptions, 0)
|
70 | 70 | }
|
| 71 | + |
| 72 | +// TestTranslateOptionsCMABOptions tests the new CMAB-related options |
| 73 | +func TestTranslateOptionsCMABOptions(t *testing.T) { |
| 74 | + // Test IGNORE_CMAB_CACHE option |
| 75 | + options := []string{"IGNORE_CMAB_CACHE"} |
| 76 | + translatedOptions, err := TranslateOptions(options) |
| 77 | + assert.NoError(t, err) |
| 78 | + assert.Len(t, translatedOptions, 1) |
| 79 | + assert.Equal(t, IgnoreCMABCache, translatedOptions[0]) |
| 80 | + |
| 81 | + // Test RESET_CMAB_CACHE option |
| 82 | + options = []string{"RESET_CMAB_CACHE"} |
| 83 | + translatedOptions, err = TranslateOptions(options) |
| 84 | + assert.NoError(t, err) |
| 85 | + assert.Len(t, translatedOptions, 1) |
| 86 | + assert.Equal(t, ResetCMABCache, translatedOptions[0]) |
| 87 | + |
| 88 | + // Test INVALIDATE_USER_CMAB_CACHE option |
| 89 | + options = []string{"INVALIDATE_USER_CMAB_CACHE"} |
| 90 | + translatedOptions, err = TranslateOptions(options) |
| 91 | + assert.NoError(t, err) |
| 92 | + assert.Len(t, translatedOptions, 1) |
| 93 | + assert.Equal(t, InvalidateUserCMABCache, translatedOptions[0]) |
| 94 | + |
| 95 | + // Test all CMAB options together |
| 96 | + options = []string{"IGNORE_CMAB_CACHE", "RESET_CMAB_CACHE", "INVALIDATE_USER_CMAB_CACHE"} |
| 97 | + translatedOptions, err = TranslateOptions(options) |
| 98 | + assert.NoError(t, err) |
| 99 | + assert.Len(t, translatedOptions, 3) |
| 100 | + assert.Equal(t, IgnoreCMABCache, translatedOptions[0]) |
| 101 | + assert.Equal(t, ResetCMABCache, translatedOptions[1]) |
| 102 | + assert.Equal(t, InvalidateUserCMABCache, translatedOptions[2]) |
| 103 | + |
| 104 | + // Test CMAB options with other options |
| 105 | + options = []string{"DISABLE_DECISION_EVENT", "IGNORE_CMAB_CACHE", "ENABLED_FLAGS_ONLY", "RESET_CMAB_CACHE", "INVALIDATE_USER_CMAB_CACHE"} |
| 106 | + translatedOptions, err = TranslateOptions(options) |
| 107 | + assert.NoError(t, err) |
| 108 | + assert.Len(t, translatedOptions, 5) |
| 109 | + assert.Equal(t, DisableDecisionEvent, translatedOptions[0]) |
| 110 | + assert.Equal(t, IgnoreCMABCache, translatedOptions[1]) |
| 111 | + assert.Equal(t, EnabledFlagsOnly, translatedOptions[2]) |
| 112 | + assert.Equal(t, ResetCMABCache, translatedOptions[3]) |
| 113 | + assert.Equal(t, InvalidateUserCMABCache, translatedOptions[4]) |
| 114 | +} |
0 commit comments