summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-01-11 13:56:52 -0800
committerGitHub <noreply@github.com>2017-01-11 13:56:52 -0800
commit00e7bb54cd90e9080f24e19d3beca604fa070afc (patch)
tree1b0bf2046c655a730e01d0e5b35f2ad8a54ee71a /spec/unit
parentc79ed56d52ecff6452740e14ebb9546f3baf399e (diff)
parentaebaee14c2d6c106914d1b3e3c9c3cbdf5bc29cb (diff)
downloadchef-00e7bb54cd90e9080f24e19d3beca604fa070afc.tar.gz
Merge pull request #4894 from chef/lcg/dnf-provider
DNF Provider PR #2
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/resource/dnf_package_spec.rb99
-rw-r--r--spec/unit/resource/yum_package_spec.rb20
2 files changed, 119 insertions, 0 deletions
diff --git a/spec/unit/resource/dnf_package_spec.rb b/spec/unit/resource/dnf_package_spec.rb
new file mode 100644
index 0000000000..0cc673d897
--- /dev/null
+++ b/spec/unit/resource/dnf_package_spec.rb
@@ -0,0 +1,99 @@
+#
+# Copyright:: Copyright 2016, Chef Software, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require "spec_helper"
+require "support/shared/unit/resource/static_provider_resolution"
+
+describe Chef::Resource::DnfPackage, "initialize" do
+
+ static_provider_resolution(
+ resource: Chef::Resource::DnfPackage,
+ provider: Chef::Provider::Package::Dnf,
+ name: :dnf_package,
+ action: :install,
+ os: "linux",
+ platform_family: "rhel"
+ )
+
+end
+
+describe Chef::Resource::DnfPackage, "arch" do
+ before(:each) do
+ @resource = Chef::Resource::DnfPackage.new("foo")
+ end
+
+ it "should set the arch variable to whatever is passed in" do
+ @resource.arch("i386")
+ expect(@resource.arch).to eql(["i386"])
+ end
+end
+
+describe Chef::Resource::DnfPackage, "flush_cache" do
+ before(:each) do
+ @resource = Chef::Resource::DnfPackage.new("foo")
+ end
+
+ it "should default the flush timing to false" do
+ flush_hash = { :before => false, :after => false }
+ expect(@resource.flush_cache).to eq(flush_hash)
+ end
+
+ it "should allow you to set the flush timing with an array" do
+ flush_array = [ :before, :after ]
+ flush_hash = { :before => true, :after => true }
+ @resource.flush_cache(flush_array)
+ expect(@resource.flush_cache).to eq(flush_hash)
+ end
+
+ it "should allow you to set the flush timing with a hash" do
+ flush_hash = { :before => true, :after => true }
+ @resource.flush_cache(flush_hash)
+ expect(@resource.flush_cache).to eq(flush_hash)
+ end
+
+ it "should allow 'true' for flush_cache" do
+ @resource.flush_cache(true)
+ expect(@resource.flush_cache).to eq({ before: true, after: true })
+ end
+
+ it "should allow 'false' for flush_cache" do
+ @resource.flush_cache(false)
+ expect(@resource.flush_cache).to eq({ before: false, after: false })
+ end
+
+ it "should allow ':before' for flush_cache" do
+ @resource.flush_cache(:before)
+ expect(@resource.flush_cache).to eq({ before: true, after: false })
+ end
+
+ it "should allow ':after' for flush_cache" do
+ @resource.flush_cache(:after)
+ expect(@resource.flush_cache).to eq({ before: false, after: true })
+ end
+end
+
+describe Chef::Resource::DnfPackage, "allow_downgrade" do
+ before(:each) do
+ @resource = Chef::Resource::DnfPackage.new("foo")
+ end
+
+ it "should allow you to specify whether allow_downgrade is true or false" do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ expect { @resource.allow_downgrade true }.not_to raise_error
+ expect { @resource.allow_downgrade false }.not_to raise_error
+ end
+end
diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb
index dd0d3ae928..bc2d19d50e 100644
--- a/spec/unit/resource/yum_package_spec.rb
+++ b/spec/unit/resource/yum_package_spec.rb
@@ -65,6 +65,26 @@ describe Chef::Resource::YumPackage, "flush_cache" do
@resource.flush_cache(flush_hash)
expect(@resource.flush_cache).to eq(flush_hash)
end
+
+ it "should allow 'true' for flush_cache" do
+ @resource.flush_cache(true)
+ expect(@resource.flush_cache).to eq({ before: true, after: true })
+ end
+
+ it "should allow 'false' for flush_cache" do
+ @resource.flush_cache(false)
+ expect(@resource.flush_cache).to eq({ before: false, after: false })
+ end
+
+ it "should allow ':before' for flush_cache" do
+ @resource.flush_cache(:before)
+ expect(@resource.flush_cache).to eq({ before: true, after: false })
+ end
+
+ it "should allow ':after' for flush_cache" do
+ @resource.flush_cache(:after)
+ expect(@resource.flush_cache).to eq({ before: false, after: true })
+ end
end
describe Chef::Resource::YumPackage, "allow_downgrade" do