test(map): standardise map.jinja verification

* Automated using https://github.com/myii/ssf-formula/pull/281
This commit is contained in:
Imran Iqbal
2020-12-22 00:43:03 +00:00
parent 7af3bf255d
commit 2bab68f5ff
6 changed files with 54 additions and 15 deletions
@@ -1,13 +1,23 @@
# frozen_string_literal: true
mapdata_file = "_mapdata/#{system.platform[:finger].split('.').first}.yaml"
mapdata_dump = inspec.profile.file(mapdata_file)
require 'yaml'
control '`map.jinja` YAML dump' do
title 'should contain the lines'
title 'should match the comparison file'
describe file('/tmp/salt_mapdata_dump.yaml') do
it { should exist }
its('content') { should eq mapdata_dump }
# Strip the `platform[:finger]` version number down to the "OS major release"
mapdata_file = "_mapdata/#{system.platform[:finger].split('.').first}.yaml"
# Load the mapdata from profile https://docs.chef.io/inspec/profiles/#profile-files
mapdata_dump = YAML.safe_load(inspec.profile.file(mapdata_file))
# Derive the location of the dumped mapdata
output_dir = platform[:family] == 'windows' ? '/temp' : '/tmp'
output_file = "#{output_dir}/salt_mapdata_dump.yaml"
describe 'File content' do
it 'should match profile map data exactly' do
expect(yaml(output_file).params).to eq(mapdata_dump)
end
end
end