inspec/test/unit/resources/oneget_test.rb

43 lines
1.3 KiB
Ruby
Raw Normal View History

require "helper"
require "inspec/resource"
require "inspec/resources/oneget"
2015-09-10 11:35:15 +00:00
describe "Inspec::Resources::OneGet" do
2015-09-10 11:35:15 +00:00
it "verify oneget package detail parsing" do
resource = MockLoader.new(:windows).load_resource("oneget", "Mozilla Firefox")
2015-09-22 16:33:05 +00:00
pkg = {
name: "Mozilla Firefox 40.0.3 (x86 en-US)",
version: "40.0.3",
type: "oneget",
2015-09-22 16:33:05 +00:00
installed: true,
}
_(resource.installed?).must_equal true
_(resource.version).must_equal "40.0.3"
2015-10-02 09:09:47 +00:00
_(resource.info).must_equal pkg
end
# catch cases where we recieve multiple return values
# eg. happens if you do 'choco install ruby'
it "filter dups of Get-Package" do
resource = MockLoader.new(:windows).load_resource("oneget", "Ruby 2.1.6-p336-x64")
2015-10-02 09:09:47 +00:00
pkg = {
name: "Ruby 2.1.6-p336-x64",
version: "2.1.6-p336",
type: "oneget",
2015-10-02 09:09:47 +00:00
installed: true,
}
_(resource.installed?).must_equal true
_(resource.version).must_equal "2.1.6-p336"
2015-10-02 09:09:47 +00:00
_(resource.info).must_equal pkg
end
it "should skip on linux" do
resource = MockLoader.new(:centos7).load_resource("oneget", "Not available")
pkg = { type: "oneget", installed: false }
2015-10-02 09:09:47 +00:00
_(resource.installed?).must_equal false
_(resource.version).must_be_nil
2015-09-22 16:33:05 +00:00
_(resource.info).must_equal pkg
2015-09-10 11:35:15 +00:00
end
end