diff --git a/lib/chef/knife/azure_vnet_list.rb b/lib/chef/knife/azure_vnet_list.rb index 1d53965..275068f 100644 --- a/lib/chef/knife/azure_vnet_list.rb +++ b/lib/chef/knife/azure_vnet_list.rb @@ -38,9 +38,9 @@ class Chef cols = ['Name', 'Affinity Group', 'State'] the_list = cols.map { |col| ui.color(col, :bold) } - connection.vnets.all.each do |ag| + connection.vnets.all.each do |vnet| %w(name affinity_group state).each do |attr| - the_list << ag.send(attr).to_s + the_list << vnet.send(attr).to_s end end diff --git a/spec/functional/ag_test.rb b/spec/functional/ag_test.rb new file mode 100644 index 0000000..4c4e310 --- /dev/null +++ b/spec/functional/ag_test.rb @@ -0,0 +1,25 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe 'ags' do + before(:all) do + @connection = Azure::Connection.new(TEST_PARAMS) + end + + it 'create' do + rsp = @connection.ags.create(azure_ag_name: 'func-test-new-ag', + azure_location: 'West US') + rsp.at_css('Status').should_not be_nil + rsp.at_css('Status').content.should eq('Succeeded') + end + + specify { @connection.ags.exists?('notexist').should eq(false) } + specify { @connection.ags.exists?('func-test-new-ag').should eq(true) } + + it 'run through' do + @connection.ags.all.each do |ag| + ag.name.should_not be_nil + ag.location.should_not be_nil + end + end + +end diff --git a/spec/functional/vnet_test.rb b/spec/functional/vnet_test.rb new file mode 100644 index 0000000..3a12840 --- /dev/null +++ b/spec/functional/vnet_test.rb @@ -0,0 +1,30 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe 'vnets' do + before(:all) do + @connection = Azure::Connection.new(TEST_PARAMS) + @connection.ags.create(azure_ag_name: 'func-test-agforvnet', + azure_location: 'West US') + end + + it 'create' do + rsp = @connection.vnets.create( + azure_vnet_name: 'func-test-new-vnet', + azure_ag_name: 'func-test-agforvnet', + azure_address_space: '10.0.0.0/16') + rsp.at_css('Status').should_not be_nil + rsp.at_css('Status').content.should eq('Succeeded') + end + + specify { @connection.vnets.exists?('notexist').should eq(false) } + specify { @connection.vnets.exists?('func-test-new-vnet').should eq(true) } + + it 'run through' do + @connection.vnets.all.each do |vnet| + vnet.name.should_not be_nil + vnet.affinity_group.should_not be_nil + vnet.state.should_not be_nil + end + end + +end