Skip to content

Commit e8a43a0

Browse files
authored
Merge pull request #64 from github/add-logs
feat: add custom error for when a file can't be parsed from the cache
2 parents 1a34939 + dcbb6b7 commit e8a43a0

File tree

5 files changed

+17
-2
lines changed

5 files changed

+17
-2
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
entitlements-app (1.2.0)
4+
entitlements-app (1.2.1)
55
concurrent-ruby (~> 1.3, >= 1.3.1)
66
faraday (~> 2.0)
77
logger (~> 1.6)

lib/entitlements/data/groups/cached.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def self.load_caches(dir)
5151
Entitlements.cache[:predictive_state][:by_ou][ou] ||= {}
5252
Entitlements.cache[:predictive_state][:by_ou][ou][identifier] = member_set
5353
Entitlements.cache[:predictive_state][:by_dn][dn] = { members: member_set, metadata: metadata }
54+
rescue => e
55+
raise "Failed to load predictive state cache file #{filename}: #{e.message}"
5456
end
5557

5658
Entitlements.logger.debug "Loaded #{Entitlements.cache[:predictive_state][:by_ou].keys.size} OU(s) from cache"

lib/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Entitlements
44
module Version
5-
VERSION = "1.2.0"
5+
VERSION = "1.2.1"
66
end
77
end

spec/unit/entitlements/data/groups/cached_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@
1717
end
1818
end
1919

20+
context "with a file that fails to parse" do
21+
let(:dir) { fixture("predictive-state/failing-cache") }
22+
23+
it "raises with a custom message" do
24+
expect(logger).to receive(:debug).with("Loading predictive update caches from #{dir}")
25+
26+
expect do
27+
described_class.load_caches(dir)
28+
end.to raise_error(RuntimeError, /Failed to load predictive state cache file/)
29+
end
30+
end
31+
2032
context "with valid predictive state directory" do
2133
let(:dir) { fixture("predictive-state/cache1") }
2234

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
metadata_is_missing_a_value

0 commit comments

Comments
 (0)