spec: validate behavior of cache register after failsafe is hit

Change-Id: Iba9f1331f4c40ce5dc73ea76e00ca19c78369506
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/331282
Reviewed-by: Isaac Moore <isaac.moore@instructure.com>
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2023-10-25 09:39:11 -06:00
parent 70a02b6ba9
commit fc0dd0ad8b
1 changed files with 7 additions and 0 deletions

View File

@ -280,6 +280,13 @@ describe Canvas::CacheRegister do
check_cache
end
it "regenerates when fetch_with_cache_register can't generate a key" do
expect(Canvas::CacheRegister.lua).to receive(:run).with(:get_with_batched_keys, anything, anything, anything).and_raise(Redis::ConnectionError.new)
expect(Rails.cache.redis).not_to receive(:set)
expect(Rails.cache.fetch_with_batched_keys("some_base_key/withstuff", batch_object: @user, batched_keys: [:enrollments, :groups]) { "some value" }).to eq "some value"
end
it "still works with expiration" do
some_key = "some_base_key/withstuff"
some_value = "some value"