mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
bugfix: write given ID to metadata json
Whenever the user provides an ID under which the profile is scoped, write it out to JSON during generation.
This commit is contained in:
parent
3b2740d015
commit
88d2b26387
2 changed files with 9 additions and 1 deletions
|
@ -33,6 +33,7 @@ module Inspec
|
|||
@params = @metadata.params
|
||||
# use the id from parameter, name or fallback to nil
|
||||
@profile_id = options[:id] || params[:name] || nil
|
||||
@params[:name] = @profile_id
|
||||
|
||||
@params[:rules] = rules = {}
|
||||
@runner = Runner.new(
|
||||
|
|
|
@ -41,7 +41,8 @@ describe Inspec::Profile do
|
|||
end
|
||||
|
||||
describe 'with simple metadata in profile' do
|
||||
let(:profile) { load_profile('simple-metadata') }
|
||||
let(:profile_id) { 'simple-metadata' }
|
||||
let(:profile) { load_profile(profile_id) }
|
||||
|
||||
it 'has metadata' do
|
||||
profile.params[:name].must_equal 'yumyum profile'
|
||||
|
@ -50,6 +51,12 @@ describe Inspec::Profile do
|
|||
it 'has no rules' do
|
||||
profile.params[:rules].must_equal({})
|
||||
end
|
||||
|
||||
it 'can overwrite the profile ID' do
|
||||
testID = rand.to_s
|
||||
res = load_profile(profile_id, id: testID)
|
||||
res.params[:name].must_equal testID
|
||||
end
|
||||
end
|
||||
|
||||
describe 'with simple metadata in profile (legacy mode)' do
|
||||
|
|
Loading…
Reference in a new issue