Skip to content

Commit

Permalink
Handle long crystalball spec key name entries in yaml dump
Browse files Browse the repository at this point in the history
flag=none

Test-plan:
- build map in jenkins
- push map to s3 manually
- reference map in test PS

Change-Id: I78c0c57f970256f84120fe3c336e882d6f3d41e2
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/284590
Tested-by: Service Cloud Jenkins <[email protected]>
Reviewed-by: James Butters <[email protected]>
QA-Review: James Butters <[email protected]>
Product-Review: James Butters <[email protected]>
  • Loading branch information
brianlwatson committed Feb 8, 2022
1 parent d780f09 commit aa2e095
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/support/crystalball.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@ def includes_root?(prediction_list)
prediction_list.include?(ENV["CRYSTALBALL_TEST_SUITE_ROOT"])
end
end

class MapStorage
# YAML persistence adapter for execution map storage
class YAMLStorage
def dump(data)
path.dirname.mkpath
# Any keys longer than 128 chars will have a yaml output starting with "? <value>\n:" instead of "<value>:\n", which crystalball doesn't like
data_dump = if %i[type commit timestamp version].all? { |header| data.key? header }
YAML.dump(data)
else
YAML.dump(data).gsub("? ", "").gsub("\n:", ":\n").gsub("\n -", "\n-").gsub("\n -", "\n-")
end
path.open("a") { |f| f.write data_dump }
end
end
end
end

require "crystalball/rspec/runner/configuration"

0 comments on commit aa2e095

Please sign in to comment.