diff options
author | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-12 16:02:57 -0600 |
---|---|---|
committer | Jay Mundrawala <jdmundrawala@gmail.com> | 2015-02-12 16:02:57 -0600 |
commit | 0df0e36f82e24cfb7cb22eaef0c8d99002a177b8 (patch) | |
tree | 2e629b5a0b4a1a315e3c08aeda33bf7201684f1a /spec/unit/util | |
parent | ab6aeedae48d37bca177a983232f35b518557d2f (diff) | |
parent | 0f794c42243138b1b0cdcfa572ed805274562c68 (diff) | |
download | chef-0df0e36f82e24cfb7cb22eaef0c8d99002a177b8.tar.gz |
Merge pull request #2779 from chef/jdm/dsc_script_imports
Allow dsc_script to import dsc resources
Diffstat (limited to 'spec/unit/util')
-rw-r--r-- | spec/unit/util/dsc/configuration_generator_spec.rb | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb index e75e285d43..9fbd3aaa51 100644 --- a/spec/unit/util/dsc/configuration_generator_spec.rb +++ b/spec/unit/util/dsc/configuration_generator_spec.rb @@ -130,7 +130,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do [a,b].join("++") end allow(file_like_object).to receive(:write) - conf_man.send(:write_document_generation_script, 'file', 'hello') + conf_man.send(:write_document_generation_script, 'file', 'hello', {}) expect(file_like_object).to have_received(:write) end end @@ -158,7 +158,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do describe "#configuration_code" do it "should build dsc" do - dsc = conf_man.send(:configuration_code, 'archive{}', 'hello') + dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {}) found_configuration = false dsc.split(';').each do |command| if command.downcase =~ /\s*configuration\s+'hello'\s*\{\s*node\s+'localhost'\s*\{\s*archive\s*\{\s*\}\s*\}\s*\}\s*/ @@ -167,5 +167,27 @@ describe Chef::Util::DSC::ConfigurationGenerator do end expect(found_configuration).to be_truthy end + context "with imports" do + it "should import all resources when a module has an empty list" do + dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => []}) + expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/) + end + + it "should import all resources when a module has a list with *" do + dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', '*', 'BarResource']}) + expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/) + end + + it "should import specific resources when a module has list without * that is not empty" do + dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', 'BarResource']}) + expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) + end + + it "should import multiple modules with multiple import statements" do + dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', 'BarResource'], 'BazModule' => []}) + expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) + expect(dsc).to match(/Import-DscResource -ModuleName BazModule\s*\n/) + end + end end end |