From faf7f44a428362b244f3640ec7244b4a901e64dd Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Sat, 5 Sep 2015 20:09:04 +0200 Subject: [PATCH] add os_env unit test --- test/helper.rb | 3 ++- test/unit/mock/cmd/PATH | 1 + test/unit/resource_os_env_test.rb | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/unit/mock/cmd/PATH create mode 100644 test/unit/resource_os_env_test.rb diff --git a/test/helper.rb b/test/helper.rb index ee183ee68..64c65cffd 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -20,7 +20,8 @@ def loadResource (resource, *args) 'ps aux' => IO::File.join(scriptpath, '/unit/mock/cmd/ps-aux'), 'type win_secpol.cfg' => IO::File.join(scriptpath, '/unit/mock/cmd/secedit-export'), 'secedit /export /cfg win_secpol.cfg' => IO::File.join(scriptpath, '/unit/mock/cmd/success'), - 'del win_secpol.cfg' => IO::File.join(scriptpath, '/unit/mock/cmd/success') + 'del win_secpol.cfg' => IO::File.join(scriptpath, '/unit/mock/cmd/success'), + 'su - root -c \'echo $PATH\'' => IO::File.join(scriptpath, '/unit/mock/cmd/PATH') } # create mock backend diff --git a/test/unit/mock/cmd/PATH b/test/unit/mock/cmd/PATH new file mode 100644 index 000000000..63b737ffa --- /dev/null +++ b/test/unit/mock/cmd/PATH @@ -0,0 +1 @@ +/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin diff --git a/test/unit/resource_os_env_test.rb b/test/unit/resource_os_env_test.rb new file mode 100644 index 000000000..cb5119174 --- /dev/null +++ b/test/unit/resource_os_env_test.rb @@ -0,0 +1,15 @@ +# encoding: utf-8 + +require 'helper' +require 'vulcano/resource' + +describe 'Vulcano::Resources::OsEnv' do + describe 'os_env' do + let(:resource) { loadResource('os_env', 'PATH') } + + it 'verify ntp config parsing' do + _(resource.split).must_equal %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin} + end + + end +end