inspec/test/unit/resources/filesystem_test.rb
Vern Burton 55abdebdc9 filesystem resource: inspect linux filesystems (#2441)
* adding df resource

Signed-off-by: Vern Burton <me@vernburton.com>

* adding unit tests and required mocks for them, created integration test

Signed-off-by: Vern Burton <me@vernburton.com>

* cleaning up skip test to include only the filename and not full path

Signed-off-by: Vern Burton <me@vernburton.com>

* adding docs

Signed-off-by: Vern Burton <me@vernburton.com>

* size makes more sense than space

Signed-off-by: Vern Burton <me@vernburton.com>

* removing unneeded author lines

Signed-off-by: Vern Burton <me@vernburton.com>

* as the command changed, changing mock to the new sha

Signed-off-by: Vern Burton <me@vernburton.com>

* updating to address comments from #2441

* removing author lines
* using attr_reader functions
* using ruby string functions rather than pipe to sed
* adding os family detection
* using ResourceFailed as the pattern already existed for OS family detection
* using if for future case support for unix and unix-like (FreeBSD)

Signed-off-by: Vern Burton <me@vernburton.com>

* adding supports to resource metadata, and adding tests that show that resource says that it is not supported on windows/unix.

Signed-off-by: Vern Burton <me@vernburton.com>

* focusing on linux os family and removing logic for assumed future cases

Signed-off-by: Vern Burton <me@vernburton.com>

* changing df to filesystem

Signed-off-by: Vern Burton <me@vernburton.com>
2018-01-25 09:29:31 -05:00

33 lines
1 KiB
Ruby

require 'helper'
require 'inspec/resource'
describe 'Inspec::Resources::FileSystemResource' do
describe 'when loading filesystem in linux' do
let (:resource) { load_resource('filesystem', '/') }
it 'resolves the / partition' do
_(resource.partition).must_equal '/'
end
it 'has more than 1 MB' do
_(resource.size).must_be :>=, 1
end
it 'must equal 28252316 MB' do
_(resource.size).must_equal 28252316
end
end
describe 'when loading filesystem in unsupported OS family' do
it 'fails on Windows' do
resource_fail = MockLoader.new(:windows).load_resource('filesystem', '/')
expect = 'Resource Filesystem is not supported on platform windows/6.2.9200.'
resource_fail.check_supports.must_equal expect
end
it 'fails on FreeBSD (unix-like)' do
resource_fail = MockLoader.new(:freebsd10).load_resource('filesystem', '/')
expect = 'Resource Filesystem is not supported on platform freebsd/10.'
resource_fail.check_supports.must_equal expect
end
end
end