summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-08-05 11:47:58 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-08-05 11:47:58 -0700
commit332e3f62f3840b838c54bbca03343680781fdb96 (patch)
treeaa9553a5fbce36cd90a5fcc98e39624314759153
parent0d79332d54ec135f534c19095e402b85ec18b876 (diff)
downloadchef-lcg/apt-update-noop.tar.gz
add tests for noopinglcg/apt-update-noop
-rw-r--r--spec/unit/resource/apt_repository_spec.rb16
-rw-r--r--spec/unit/resource/apt_update_spec.rb16
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