2019-06-11 22:24:35 +00:00
|
|
|
require "helper"
|
|
|
|
require "inspec/resource"
|
|
|
|
require "inspec/resources/file" # TODO: rename this test file?
|
|
|
|
require "inspec/resources/mount"
|
2015-12-31 00:10:06 +00:00
|
|
|
|
2016-03-09 09:35:35 +00:00
|
|
|
describe Inspec::Resources::FileResource do
|
2019-06-11 22:24:35 +00:00
|
|
|
let(:root_resource) { load_resource("mount", "/") }
|
2015-12-31 00:10:06 +00:00
|
|
|
|
2022-06-02 15:55:58 +00:00
|
|
|
it "generates the resource_id for current resource" do
|
|
|
|
_(root_resource.resource_id).must_equal "/"
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "parses the mount data properly" do
|
2019-09-30 22:31:55 +00:00
|
|
|
_(root_resource.send(:device)).must_equal("/dev/xvda1")
|
|
|
|
_(root_resource.send(:type)).must_equal("ext4")
|
|
|
|
_(root_resource.send(:options)).must_equal(%w{rw discard})
|
|
|
|
_(root_resource.send(:count)).must_equal(1)
|
2016-01-02 23:01:26 +00:00
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
let(:iso_resource) { load_resource("mount", "/mnt/iso-disk") }
|
2016-01-02 23:01:26 +00:00
|
|
|
|
2022-06-02 15:55:58 +00:00
|
|
|
it "generates resource_id for current resource" do
|
|
|
|
_(iso_resource.resource_id).must_equal "/mnt/iso-disk"
|
|
|
|
end
|
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "parses the mount data properly" do
|
2019-09-30 22:31:55 +00:00
|
|
|
_(iso_resource.send(:device)).must_equal("/root/alpine-3.3.0-x86_64_2.iso")
|
|
|
|
_(iso_resource.send(:type)).must_equal("iso9660")
|
|
|
|
_(iso_resource.send(:options)).must_equal(["ro"])
|
|
|
|
_(iso_resource.send(:count)).must_equal(2)
|
2015-12-31 00:10:06 +00:00
|
|
|
end
|
2017-11-01 11:01:21 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
let(:ws_resource) { load_resource("mount", "/mnt/Research & Development") }
|
2017-11-01 11:01:21 +00:00
|
|
|
|
2019-06-11 22:24:35 +00:00
|
|
|
it "parses the mount data properly even if whitespaces are included" do
|
2019-09-30 22:31:55 +00:00
|
|
|
_(ws_resource.send(:device)).must_equal("//fileserver.corp.internal/Research & Development")
|
|
|
|
_(ws_resource.send(:type)).must_equal("cifs")
|
|
|
|
_(ws_resource.send(:options)).must_equal(["rw", "vers=1.0"])
|
|
|
|
_(ws_resource.send(:count)).must_equal(1)
|
2017-11-01 11:01:21 +00:00
|
|
|
end
|
2015-12-31 00:10:06 +00:00
|
|
|
end
|