|
61 | 61 | adapter.features |
62 | 62 | expect(cache.read("flipper/v1/features")).not_to be(nil) |
63 | 63 |
|
| 64 | + adapter.get_all |
| 65 | + expect(cache.read("flipper/v1/get_all")).not_to be(nil) |
| 66 | + |
64 | 67 | # expire cache |
65 | 68 | adapter.expire_features_cache |
66 | 69 | expect(cache.read("flipper/v1/features")).to be(nil) |
| 70 | + expect(cache.read("flipper/v1/get_all")).to be(nil) |
67 | 71 | end |
68 | 72 |
|
69 | 73 | it "can expire feature cache" do |
70 | 74 | # cache the features |
71 | 75 | adapter.get(flipper[:stats]) |
72 | 76 | expect(cache.read("flipper/v1/feature/stats")).not_to be(nil) |
73 | 77 |
|
| 78 | + adapter.get_all |
| 79 | + expect(cache.read("flipper/v1/get_all")).not_to be(nil) |
| 80 | + |
74 | 81 | # expire cache |
75 | 82 | adapter.expire_feature_cache("stats") |
76 | 83 | expect(cache.read("flipper/v1/feature/stats")).to be(nil) |
| 84 | + expect(cache.read("flipper/v1/get_all")).to be(nil) |
77 | 85 | end |
78 | 86 |
|
79 | 87 | it "can generate feature cache key" do |
|
88 | 96 | expect(adapter.features_cache_key).to eq("foo/flipper/v1/features") |
89 | 97 | end |
90 | 98 |
|
| 99 | + it "knows get_all_cache_key" do |
| 100 | + expect(adapter.get_all_cache_key).to eq("foo/flipper/v1/get_all") |
| 101 | + end |
| 102 | + |
91 | 103 | it "can generate feature cache key" do |
92 | 104 | expect(adapter.feature_cache_key("stats")).to eq("foo/flipper/v1/feature/stats") |
93 | 105 | end |
|
109 | 121 | adapter.get_all |
110 | 122 |
|
111 | 123 | # verify cached with prefix |
| 124 | + get_all_cache_value = cache.read("foo/flipper/v1/get_all") |
112 | 125 | expect(cache.read("foo/flipper/v1/features")).to eq(Set["stats", "search"]) |
113 | | - expect(cache.read("foo/flipper/v1/feature/search")[:percentage_of_actors]).to eq("10") |
114 | | - expect(cache.read("foo/flipper/v1/feature/stats")[:boolean]).to eq("true") |
| 126 | + expect(get_all_cache_value["search"][:percentage_of_actors]).to eq("10") |
| 127 | + expect(get_all_cache_value["stats"][:boolean]).to eq("true") |
115 | 128 | end |
116 | 129 | end |
117 | 130 |
|
|
120 | 133 |
|
121 | 134 | before do |
122 | 135 | adapter.get(feature) |
| 136 | + adapter.get_all |
123 | 137 | adapter.remove(feature) |
124 | 138 | end |
125 | 139 |
|
126 | 140 | it 'expires feature and deletes the cache' do |
127 | 141 | expect(cache.read("flipper/v1/feature/#{feature.key}")).to be_nil |
| 142 | + expect(cache.read("flipper/v1/get_all")).to be(nil) |
128 | 143 | expect(cache.exist?("flipper/v1/feature/#{feature.key}")).to be(false) |
129 | 144 | expect(feature).not_to be_enabled |
130 | 145 | end |
|
144 | 159 | let(:feature) { flipper[:stats] } |
145 | 160 |
|
146 | 161 | before do |
| 162 | + adapter.get(feature) |
| 163 | + adapter.get_all |
147 | 164 | adapter.enable(feature, feature.gate(:boolean), Flipper::Types::Boolean.new(true)) |
148 | 165 | end |
149 | 166 |
|
150 | 167 | it 'enables feature and deletes the cache' do |
| 168 | + expect(cache.read("flipper/v1/get_all")).to be(nil) |
151 | 169 | expect(cache.read("flipper/v1/feature/#{feature.key}")).to be_nil |
152 | 170 | expect(cache.exist?("flipper/v1/feature/#{feature.key}")).to be(false) |
153 | 171 | expect(feature).to be_enabled |
|
157 | 175 | let(:write_through) { true } |
158 | 176 |
|
159 | 177 | it 'expires feature and writes to the cache' do |
| 178 | + expect(cache.read("flipper/v1/get_all")).to be(nil) |
160 | 179 | expect(cache.exist?("flipper/v1/feature/#{feature.key}")).to be(true) |
161 | 180 | expect(cache.read("flipper/v1/feature/#{feature.key}")).to include(boolean: 'true') |
162 | 181 | expect(feature).to be_enabled |
|
168 | 187 | let(:feature) { flipper[:stats] } |
169 | 188 |
|
170 | 189 | before do |
| 190 | + adapter.get(feature) |
| 191 | + adapter.get_all |
171 | 192 | adapter.disable(feature, feature.gate(:boolean), Flipper::Types::Boolean.new) |
172 | 193 | end |
173 | 194 |
|
174 | 195 | it 'disables feature and deletes the cache' do |
| 196 | + expect(cache.read("flipper/v1/get_all")).to be(nil) |
175 | 197 | expect(cache.read("flipper/v1/feature/#{feature.key}")).to be_nil |
176 | 198 | expect(cache.exist?("flipper/v1/feature/#{feature.key}")).to be(false) |
177 | 199 | expect(feature).not_to be_enabled |
|
224 | 246 |
|
225 | 247 | it 'warms all features' do |
226 | 248 | adapter.get_all |
227 | | - expect(cache.read("flipper/v1/feature/#{stats.key}")[:boolean]).to eq('true') |
228 | | - expect(cache.read("flipper/v1/feature/#{search.key}")[:boolean]).to be(nil) |
| 249 | + get_all_cache_value = cache.read("flipper/v1/get_all") |
| 250 | + expect(get_all_cache_value).not_to be(nil) |
| 251 | + expect(get_all_cache_value["stats"][:boolean]).to eq('true') |
| 252 | + expect(get_all_cache_value["search"][:boolean]).to be(nil) |
229 | 253 | expect(cache.read("flipper/v1/features")).to eq(Set["stats", "search"]) |
230 | 254 | end |
231 | 255 |
|
|
236 | 260 | it 'only invokes two calls to wrapped adapter (for features set and gate data for each feature in set)' do |
237 | 261 | memory_adapter.reset |
238 | 262 | 5.times { adapter.get_all } |
239 | | - expect(memory_adapter.count(:features)).to eq(1) |
240 | | - expect(memory_adapter.count(:get_multi)).to eq(1) |
241 | | - expect(memory_adapter.count).to eq(2) |
| 263 | + expect(memory_adapter.count(:get_all)).to eq(1) |
| 264 | + expect(memory_adapter.count).to eq(1) |
242 | 265 | end |
243 | 266 | end |
244 | 267 |
|
|
0 commit comments