From 60f80b9f97dbb45c5d6572a361040c1c5242990d Mon Sep 17 00:00:00 2001 From: Sonu Saha Date: Thu, 2 Jun 2022 16:46:45 +0530 Subject: [PATCH] CFINSPEC-274: Add resource_id & unit test: zfs_pool Signed-off-by: Sonu Saha --- lib/inspec/resources/zfs_pool.rb | 4 ++++ test/unit/resources/zfs_pool_test.rb | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/inspec/resources/zfs_pool.rb b/lib/inspec/resources/zfs_pool.rb index 1c974d44b..235192ccf 100644 --- a/lib/inspec/resources/zfs_pool.rb +++ b/lib/inspec/resources/zfs_pool.rb @@ -31,6 +31,10 @@ module Inspec::Resources inspec.command("#{@zpool_cmd} get -Hp all #{@zfs_pool}").exit_status == 0 end + def resource_id + @zfs_pool + end + def to_s "ZFS Pool #{@zfs_pool}" end diff --git a/test/unit/resources/zfs_pool_test.rb b/test/unit/resources/zfs_pool_test.rb index 9aaa638e7..686251837 100644 --- a/test/unit/resources/zfs_pool_test.rb +++ b/test/unit/resources/zfs_pool_test.rb @@ -12,6 +12,7 @@ describe Inspec::Resources::ZfsPool do _(tank_resource.send(:guid)).must_equal("4711279777582057513") _(tank_resource.send(:failmode)).must_equal("continue") _(tank_resource.send(:'feature@lz4_compress')).must_equal("active") + _(tank_resource.resource_id).must_equal "tank" end end end @@ -26,6 +27,7 @@ describe Inspec::Resources::ZfsPool do _(tank_resource.send(:guid)).must_equal("4711279777582057513") _(tank_resource.send(:failmode)).must_equal("continue") _(tank_resource.send(:'feature@lz4_compress')).must_equal("active") + _(tank_resource.resource_id).must_equal "tank" end end end @@ -37,6 +39,7 @@ describe Inspec::Resources::ZfsPool do it "parses the ZFS pool data properly" do if _(tank_resource) _(tank_resource.resource_exception_message).must_equal("zfs is not installed") + _(tank_resource.resource_id).must_equal "tank" end end end @@ -45,5 +48,6 @@ describe Inspec::Resources::ZfsPool do it "parses the ZFS pool data properly" do resource = MockLoader.new(:macos10_16).load_resource("zfs_pool", "tank") _(resource.resource_exception_message).must_equal "zfs is not installed" + _(resource.resource_id).must_equal "tank" end end