From 0a286226c3f5ab7a4d35d45ceb073b12d5d79e55 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Mon, 30 Nov 2015 09:15:50 -0800 Subject: Fix naming of virtualbox spec --- spec/unit/plugins/virtualbox.rb | 88 ------------------------------------ spec/unit/plugins/virtualbox_spec.rb | 88 ++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 88 deletions(-) delete mode 100644 spec/unit/plugins/virtualbox.rb create mode 100644 spec/unit/plugins/virtualbox_spec.rb diff --git a/spec/unit/plugins/virtualbox.rb b/spec/unit/plugins/virtualbox.rb deleted file mode 100644 index 9719dd25..00000000 --- a/spec/unit/plugins/virtualbox.rb +++ /dev/null @@ -1,88 +0,0 @@ -# Author:: Tim Smith () -# Copyright:: Copyright (c) 2015 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) - -vbox_output = < -Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 10.0.2.15, timestamp: 1448390422248366000, flags: -Name: /VirtualBox/HostInfo/GUI/LanguageID, value: en_US, timestamp: 1448390412061749000, flags: -Name: /VirtualBox/GuestInfo/Net/0/MAC, value: 080027FBB38C, timestamp: 1448390422248652000, flags: -Name: /VirtualBox/GuestInfo/OS/ServicePack, value: , timestamp: 1448390422246976000, flags: -Name: /VirtualBox/HostInfo/VBoxVerExt, value: 5.0.10, timestamp: 1448390411701508000, flags: TRANSIENT, RDONLYGUEST -Name: /VirtualBox/GuestInfo/Net/0/V4/Netmask, value: 255.255.255.0, timestamp: 1448390422248569000, flags: -Name: /VirtualBox/GuestInfo/OS/Version, value: #36~14.04.1-Ubuntu SMP Thu Oct 8 10:21:08 UTC 2015, timestamp: 1448390422246810000, flags: -Name: /VirtualBox/GuestAdd/VersionExt, value: 5.0.2, timestamp: 1448390422247220000, flags: -Name: /VirtualBox/GuestAdd/Revision, value: 102096, timestamp: 1448390422247266000, flags: -Name: /VirtualBox/HostGuest/SysprepExec, value: , timestamp: 1448390411701168000, flags: TRANSIENT, RDONLYGUEST -Name: /VirtualBox/GuestInfo/OS/LoggedInUsers, value: 1, timestamp: 1448390452251425000, flags: TRANSIENT, TRANSRESET -Name: /VirtualBox/GuestInfo/Net/0/Status, value: Up, timestamp: 1448390422248755000, flags: -Name: /VirtualBox/GuestInfo/Net/0/Name, value: eth0, timestamp: 1448390422248814000, flags: -Name: /VirtualBox/HostGuest/SysprepArgs, value: , timestamp: 1448390411701220000, flags: TRANSIENT, RDONLYGUEST -Name: /VirtualBox/GuestAdd/Version, value: 5.0.2, timestamp: 1448390422247066000, flags: -Name: /VirtualBox/HostInfo/VBoxRev, value: 104061, timestamp: 1448390411701536000, flags: TRANSIENT, RDONLYGUEST -Name: /VirtualBox/GuestInfo/Net/0/V4/Broadcast, value: 10.0.2.255, timestamp: 1448390422248498000, flags: -Name: /VirtualBox/HostInfo/VBoxVer, value: 5.0.10, timestamp: 1448390411701485000, flags: TRANSIENT, RDONLYGUEST -Name: /VirtualBox/GuestInfo/OS/LoggedInUsersList, value: tim, timestamp: 1448390452251274000, flags: TRANSIENT, TRANSRESET -Name: /VirtualBox/GuestInfo/Net/Count, value: 1, timestamp: 1448391352440445000, flags: -Name: /VirtualBox/GuestInfo/OS/Release, value: 3.19.0-31-generic, timestamp: 1448390422246638000, flags: -Name: /VirtualBox/GuestInfo/OS/NoLoggedInUsers, value: false, timestamp: 1448390452251532000, flags: TRANSIENT, TRANSRESET -EOF - -describe Ohai::System, 'plugin virtualbox' do - context 'when VBoxControl shellout fails' do - it 'should not set the virtualbox attribute' do - plugin = get_plugin('virtualbox') - allow(plugin).to receive(:shell_out).with('VBoxControl guestproperty enumerate').and_return(mock_shell_out(1, '', '')) - plugin.run - expect(plugin).not_to have_key(:virtualbox) - end - end - - context 'when VBoxControl shellout succeeds' do - let(:plugin) { get_plugin('virtualbox') } - - before(:each) do - allow(plugin).to receive(:shell_out).with('VBoxControl guestproperty enumerate').and_return(mock_shell_out(0, vbox_output, '')) - plugin.run - end - - it 'should set the host version' do - expect(plugin[:virtualbox][:host][:version]).to eql('5.0.10') - end - - it 'should set the host revision' do - expect(plugin[:virtualbox][:host][:revision]).to eql('104061') - end - - it 'should set the host language' do - expect(plugin[:virtualbox][:host][:language]).to eql('en_US') - end - - it 'should set the guest additions version' do - expect(plugin[:virtualbox][:guest][:guest_additions_version]).to eql('5.0.2') - end - - it 'should set the guest additions revision' do - expect(plugin[:virtualbox][:guest][:guest_additions_revision]).to eql('102096') - end - end -end diff --git a/spec/unit/plugins/virtualbox_spec.rb b/spec/unit/plugins/virtualbox_spec.rb new file mode 100644 index 00000000..9719dd25 --- /dev/null +++ b/spec/unit/plugins/virtualbox_spec.rb @@ -0,0 +1,88 @@ +# Author:: Tim Smith () +# Copyright:: Copyright (c) 2015 Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '/spec_helper.rb')) + +vbox_output = < +Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 10.0.2.15, timestamp: 1448390422248366000, flags: +Name: /VirtualBox/HostInfo/GUI/LanguageID, value: en_US, timestamp: 1448390412061749000, flags: +Name: /VirtualBox/GuestInfo/Net/0/MAC, value: 080027FBB38C, timestamp: 1448390422248652000, flags: +Name: /VirtualBox/GuestInfo/OS/ServicePack, value: , timestamp: 1448390422246976000, flags: +Name: /VirtualBox/HostInfo/VBoxVerExt, value: 5.0.10, timestamp: 1448390411701508000, flags: TRANSIENT, RDONLYGUEST +Name: /VirtualBox/GuestInfo/Net/0/V4/Netmask, value: 255.255.255.0, timestamp: 1448390422248569000, flags: +Name: /VirtualBox/GuestInfo/OS/Version, value: #36~14.04.1-Ubuntu SMP Thu Oct 8 10:21:08 UTC 2015, timestamp: 1448390422246810000, flags: +Name: /VirtualBox/GuestAdd/VersionExt, value: 5.0.2, timestamp: 1448390422247220000, flags: +Name: /VirtualBox/GuestAdd/Revision, value: 102096, timestamp: 1448390422247266000, flags: +Name: /VirtualBox/HostGuest/SysprepExec, value: , timestamp: 1448390411701168000, flags: TRANSIENT, RDONLYGUEST +Name: /VirtualBox/GuestInfo/OS/LoggedInUsers, value: 1, timestamp: 1448390452251425000, flags: TRANSIENT, TRANSRESET +Name: /VirtualBox/GuestInfo/Net/0/Status, value: Up, timestamp: 1448390422248755000, flags: +Name: /VirtualBox/GuestInfo/Net/0/Name, value: eth0, timestamp: 1448390422248814000, flags: +Name: /VirtualBox/HostGuest/SysprepArgs, value: , timestamp: 1448390411701220000, flags: TRANSIENT, RDONLYGUEST +Name: /VirtualBox/GuestAdd/Version, value: 5.0.2, timestamp: 1448390422247066000, flags: +Name: /VirtualBox/HostInfo/VBoxRev, value: 104061, timestamp: 1448390411701536000, flags: TRANSIENT, RDONLYGUEST +Name: /VirtualBox/GuestInfo/Net/0/V4/Broadcast, value: 10.0.2.255, timestamp: 1448390422248498000, flags: +Name: /VirtualBox/HostInfo/VBoxVer, value: 5.0.10, timestamp: 1448390411701485000, flags: TRANSIENT, RDONLYGUEST +Name: /VirtualBox/GuestInfo/OS/LoggedInUsersList, value: tim, timestamp: 1448390452251274000, flags: TRANSIENT, TRANSRESET +Name: /VirtualBox/GuestInfo/Net/Count, value: 1, timestamp: 1448391352440445000, flags: +Name: /VirtualBox/GuestInfo/OS/Release, value: 3.19.0-31-generic, timestamp: 1448390422246638000, flags: +Name: /VirtualBox/GuestInfo/OS/NoLoggedInUsers, value: false, timestamp: 1448390452251532000, flags: TRANSIENT, TRANSRESET +EOF + +describe Ohai::System, 'plugin virtualbox' do + context 'when VBoxControl shellout fails' do + it 'should not set the virtualbox attribute' do + plugin = get_plugin('virtualbox') + allow(plugin).to receive(:shell_out).with('VBoxControl guestproperty enumerate').and_return(mock_shell_out(1, '', '')) + plugin.run + expect(plugin).not_to have_key(:virtualbox) + end + end + + context 'when VBoxControl shellout succeeds' do + let(:plugin) { get_plugin('virtualbox') } + + before(:each) do + allow(plugin).to receive(:shell_out).with('VBoxControl guestproperty enumerate').and_return(mock_shell_out(0, vbox_output, '')) + plugin.run + end + + it 'should set the host version' do + expect(plugin[:virtualbox][:host][:version]).to eql('5.0.10') + end + + it 'should set the host revision' do + expect(plugin[:virtualbox][:host][:revision]).to eql('104061') + end + + it 'should set the host language' do + expect(plugin[:virtualbox][:host][:language]).to eql('en_US') + end + + it 'should set the guest additions version' do + expect(plugin[:virtualbox][:guest][:guest_additions_version]).to eql('5.0.2') + end + + it 'should set the guest additions revision' do + expect(plugin[:virtualbox][:guest][:guest_additions_revision]).to eql('102096') + end + end +end -- cgit v1.2.1