inspec/test/unit/resources/cgroup_test.rb
Sonu Saha 4f151bd72c CFINSPEC-73: Add unit test and relevant files for cgroup
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
2022-03-23 08:40:34 +05:30

33 lines
1.4 KiB
Ruby

require "inspec/globals"
require "#{Inspec.src_root}/test/helper"
require_relative "../../../lib/inspec/resources/cgroup"
describe Inspec::Resources::Cgroup do
# ubuntu
it "check carrotking cgroup information on ubuntu" do
resource = MockLoader.new("ubuntu".to_sym).load_resource("cgroup", "carrotking")
_(resource.cpuset.cpus).must_equal 0
_(resource.memory.stat).must_match(/hierarchical_memory_limit 9223372036854771712/)
end
# debian
it "check carrotking cgroup information on debian" do
resource = MockLoader.new("debian8".to_sym).load_resource("cgroup", "carrotking")
_(resource.cpuset.cpus).must_equal 0
_(resource.memory.stat).must_match(/hierarchical_memory_limit 9223372036854771712/)
end
# windows
it "check carrotking cgroup information on windows" do
resource = MockLoader.new("windows".to_sym).load_resource("cgroup", "carrotking")
_(resource.resource_skipped?).must_equal true
_(resource.resource_exception_message).must_equal "The `cgroup` resource is not supported on your OS yet."
end
# undefined
it "check carrotking cgroup information on unsupported os" do
resource = MockLoader.new("undefined".to_sym).load_resource("cgroup", "carrotking")
_(resource.resource_skipped?).must_equal true
_(resource.resource_exception_message).must_equal "The `cgroup` resource is not supported on your OS yet."
end
end