diff options
author | Joshua Justice <jjustice6@bloomberg.net> | 2019-07-30 12:05:40 -0400 |
---|---|---|
committer | Joshua Justice <jjustice6@bloomberg.net> | 2019-07-30 12:18:11 -0400 |
commit | d7e0c9d4a83f0f83eb636fb18c2394ad982a02cf (patch) | |
tree | d3b87028860f62e85d0137941d42c2460f74c67a | |
parent | 9ea266b62c7a3ab621d405224537e19fb404230f (diff) | |
download | ohai-d7e0c9d4a83f0f83eb636fb18c2394ad982a02cf.tar.gz |
Add a unit test for the virtualization case.
Signed-off-by: Joshua Justice <jjustice6@bloomberg.net>
-rw-r--r-- | spec/unit/plugins/openstack_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/plugins/openstack_spec.rb b/spec/unit/plugins/openstack_spec.rb index bda21a33..b7208633 100644 --- a/spec/unit/plugins/openstack_spec.rb +++ b/spec/unit/plugins/openstack_spec.rb @@ -302,4 +302,24 @@ describe Ohai::System, "plugin openstack" do end end end + + context "when openstack virtualization is present" do + context "and the metadata service is not available" do + before do + allow(plugin).to receive(:can_socket_connect?) + .with(Ohai::Mixin::Ec2Metadata::EC2_METADATA_ADDR, 80, default_timeout) + .and_return(false) + plugin[:virtualization] = { system: { guest: "openstack" } } + plugin.run + end + + it "sets openstack provider attribute since virtualization is present" do + expect(plugin[:openstack][:provider]).to eq("openstack") + end + + it "doesn't set metadata attributes" do + expect(plugin[:openstack][:instance_id]).to be_nil + end + end + end end |