shared_audits_spec: guard against nil value

The return value from `eol_data` can be `nil`, so we should use a
safe navigation operator before `#dig`.
This commit is contained in:
Sam Ford 2025-05-03 20:49:53 -04:00
parent 98b919f672
commit 53c0780d85
No known key found for this signature in database
GPG Key ID: 7AF5CBEE1DD6F76D

View File

@ -38,8 +38,8 @@ RSpec.describe SharedAudits do
describe "::eol_data" do
it "returns a parsed JSON object if the product is found" do
mock_curl_output stdout: eol_json_text
expect(described_class.eol_data("product", "cycle").dig("result", "isEol")).to be(true)
expect(described_class.eol_data("product", "cycle").dig("result", "eolFrom")).to eq("2025-01-01")
expect(described_class.eol_data("product", "cycle")&.dig("result", "isEol")).to be(true)
expect(described_class.eol_data("product", "cycle")&.dig("result", "eolFrom")).to eq("2025-01-01")
end
it "returns nil if the product is not found" do