(t *testing.T)
| 109 | } |
| 110 | |
| 111 | func TestSet(t *testing.T) { |
| 112 | ctx := context.Background() |
| 113 | |
| 114 | tests := []struct { |
| 115 | name string |
| 116 | key string |
| 117 | value string |
| 118 | expectedValue string |
| 119 | expectedFound bool |
| 120 | }{ |
| 121 | { |
| 122 | name: "set new key-value pair", |
| 123 | key: "newkey", |
| 124 | value: "newvalue", |
| 125 | expectedValue: "newvalue", |
| 126 | expectedFound: true, |
| 127 | }, |
| 128 | { |
| 129 | name: "set empty value", |
| 130 | key: "emptykey", |
| 131 | value: "", |
| 132 | expectedValue: "", |
| 133 | expectedFound: true, |
| 134 | }, |
| 135 | { |
| 136 | name: "set empty key", |
| 137 | key: "", |
| 138 | value: "emptykeyvalue", |
| 139 | expectedValue: "emptykeyvalue", |
| 140 | expectedFound: true, |
| 141 | }, |
| 142 | } |
| 143 | |
| 144 | for _, tt := range tests { |
| 145 | t.Run(tt.name, func(t *testing.T) { |
| 146 | // Create a fresh cache for each test |
| 147 | testCache := NewPolicyCache(ctx) |
| 148 | |
| 149 | // Execute test |
| 150 | testCache.Set(tt.key, tt.value, nil) |
| 151 | |
| 152 | // Verify the value was set correctly |
| 153 | value, found := testCache.Get(tt.key) |
| 154 | assert.Equal(t, tt.expectedValue, value) |
| 155 | assert.Equal(t, tt.expectedFound, found) |
| 156 | }) |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | func TestNewPolicyCache(t *testing.T) { |
| 161 | tests := []struct { |
nothing calls this directly
no test coverage detected