diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-08-08 13:03:28 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-08 13:03:28 -0700 |
commit | fc5f3f49e161141d9b696ff5cfbe3af8f86f5f1e (patch) | |
tree | a2b86683751a3fc6fa101ae3da1062ca0a5949c6 /spec | |
parent | 247486f81b879e37dc297f3001b07232bb372743 (diff) | |
parent | 332e3f62f3840b838c54bbca03343680781fdb96 (diff) | |
download | chef-fc5f3f49e161141d9b696ff5cfbe3af8f86f5f1e.tar.gz |
Merge pull request #5173 from chef/lcg/apt-update-noop
noop apt_update similar to apt_repository
Diffstat (limited to 'spec')
-rw-r--r-- | spec/unit/resource/apt_repository_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/resource/apt_update_spec.rb | 16 |
2 files changed, 28 insertions, 4 deletions
diff --git a/spec/unit/resource/apt_repository_spec.rb b/spec/unit/resource/apt_repository_spec.rb index cd55ce66cc..cd21873fed 100644 --- a/spec/unit/resource/apt_repository_spec.rb +++ b/spec/unit/resource/apt_repository_spec.rb @@ -19,8 +19,10 @@ require "spec_helper" describe Chef::Resource::AptRepository do - - let(:resource) { Chef::Resource::AptRepository.new("multiverse") } + let(:node) { Chef::Node.new } + let(:events) { Chef::EventDispatch::Dispatcher.new } + let(:run_context) { Chef::RunContext.new(node, {}, events) } + let(:resource) { Chef::Resource::AptRepository.new("multiverse", run_context) } it "should create a new Chef::Resource::AptUpdate" do expect(resource).to be_a_kind_of(Chef::Resource) @@ -35,4 +37,14 @@ describe Chef::Resource::AptRepository do expect(resource.distribution(nil)).to eql(nil) expect(resource.distribution).to eql(nil) end + + it "should resolve to a Noop class when uses_apt? is false" do + expect(Chef::Provider::AptRepository).to receive(:uses_apt?).and_return(false) + expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop) + end + + it "should resolve to a AptRepository class when uses_apt? is true" do + expect(Chef::Provider::AptRepository).to receive(:uses_apt?).and_return(true) + expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::AptRepository) + end end diff --git a/spec/unit/resource/apt_update_spec.rb b/spec/unit/resource/apt_update_spec.rb index 8015cb03b3..6fcba4adce 100644 --- a/spec/unit/resource/apt_update_spec.rb +++ b/spec/unit/resource/apt_update_spec.rb @@ -19,8 +19,10 @@ require "spec_helper" describe Chef::Resource::AptUpdate do - - let(:resource) { Chef::Resource::AptUpdate.new("update") } + let(:node) { Chef::Node.new } + let(:events) { Chef::EventDispatch::Dispatcher.new } + let(:run_context) { Chef::RunContext.new(node, {}, events) } + let(:resource) { Chef::Resource::AptUpdate.new("update", run_context) } it "should create a new Chef::Resource::AptUpdate" do expect(resource).to be_a_kind_of(Chef::Resource) @@ -35,4 +37,14 @@ describe Chef::Resource::AptUpdate do resource.frequency(400) expect(resource.frequency).to eql(400) end + + it "should resolve to a Noop class when uses_apt? is false" do + expect(Chef::Provider::AptUpdate).to receive(:uses_apt?).and_return(false) + expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::Noop) + end + + it "should resolve to a AptUpdate class when uses_apt? is true" do + expect(Chef::Provider::AptUpdate).to receive(:uses_apt?).and_return(true) + expect(resource.provider_for_action(:add)).to be_a(Chef::Provider::AptUpdate) + end end |