2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/filesystem"
|
2018-01-25 14:29:31 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "Inspec::Resources::FileSystemResource" do
|
|
|
|
it "verify filesystem on linux" do
|
2019-10-24 04:41:29 +00:00
|
|
|
resource = quick_resource(:filesystem, :linux, "/") do |cmd|
|
|
|
|
stdout_file "test/unit/mock/cmd/df-PT"
|
|
|
|
end
|
|
|
|
|
2019-02-01 05:39:52 +00:00
|
|
|
_(resource.size_kb).must_equal 30428648
|
|
|
|
_(resource.size).must_equal 30428648
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.name).must_equal "/"
|
|
|
|
_(resource.type).must_equal "ext4"
|
2019-02-01 05:46:18 +00:00
|
|
|
_(resource.free_kb).must_equal 20760728
|
2019-01-31 22:18:39 +00:00
|
|
|
_(resource.percent_free).must_equal 68
|
2018-11-19 18:32:59 +00:00
|
|
|
end
|
2019-01-31 22:18:39 +00:00
|
|
|
|
2019-02-01 05:46:18 +00:00
|
|
|
# windows
|
2019-06-11 22:24:35 +00:00
|
|
|
it "verify filesystem on windows" do
|
|
|
|
resource = MockLoader.new(:windows).load_resource("filesystem", "c:")
|
2019-02-01 05:39:52 +00:00
|
|
|
_(resource.size).must_equal 38 # Windows size() had a bug that turned it into GB, not KB
|
|
|
|
_(resource.size_kb).must_equal 40000000 # approx 38 GB
|
2019-06-11 22:24:35 +00:00
|
|
|
_(resource.name).must_equal "c:"
|
|
|
|
_(resource.type).must_equal "NTFS"
|
2019-02-01 05:46:18 +00:00
|
|
|
_(resource.free_kb).must_equal 30000000
|
2019-02-01 05:39:52 +00:00
|
|
|
_(resource.percent_free).must_equal 75
|
2018-01-25 14:29:31 +00:00
|
|
|
end
|
|
|
|
|
2018-11-19 18:32:59 +00:00
|
|
|
# unsuported os
|
2019-06-11 22:24:35 +00:00
|
|
|
describe "when loading filesystem in unsupported OS family" do
|
|
|
|
it "fails on FreeBSD (unix-like)" do
|
|
|
|
resource_fail = MockLoader.new(:freebsd10).load_resource("filesystem", "/")
|
2019-09-30 22:31:55 +00:00
|
|
|
_(resource_fail.check_supports).must_equal false
|
2018-01-25 14:29:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|