Skip to content

Commit

Permalink
Add VirtualMachineSizes collection
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinLoiseau committed Oct 30, 2018
1 parent a6034dc commit 45c77ce
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/fog/azurerm/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AzureRM < Fog::Service
model :virtual_machine_extension
collection :virtual_machine_extensions
model :virtual_machine_size
collection :virtual_machine_sizes
model :managed_disk
collection :managed_disks
model :data_disk
Expand Down
4 changes: 4 additions & 0 deletions lib/fog/azurerm/models/compute/virtual_machine_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ class VirtualMachineSize < Fog::Model
attribute :number_of_cores
attribute :os_disk_size_in_mb
attribute :resource_disk_size_in_mb

def self.parse(virtual_machine_size)
get_hash_from_object(virtual_machine_size)
end
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions lib/fog/azurerm/models/compute/virtual_machine_sizes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Fog
module Compute
class AzureRM
class VirtualMachineSizes < Fog::Collection
attribute :location
model Fog::Compute::AzureRM::VirtualMachineSize
end
end
end
end
7 changes: 7 additions & 0 deletions test/models/compute/test_virtual_machine_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ def test_model_attributes
assert_respond_to @virtual_machine_size, attribute
end
end

def test_parse_method
virtual_machine_size_hash = Fog::Compute::AzureRM::VirtualMachineSize.parse(@response)
@response.instance_variables.each do |attribute|
assert_equal @response.instance_variable_get(attribute), virtual_machine_size_hash[attribute.to_s.delete('@')]
end
end
end
12 changes: 12 additions & 0 deletions test/models/compute/test_virtual_machine_sizes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require File.expand_path '../../test_helper', __dir__
# Test class for Managed Disk Collection
class TestVirtualMachineSizes < Minitest::Test
def setup
@service = Fog::Compute::AzureRM.new(credentials)
@virtual_machine_sizes = Fog::Compute::AzureRM::VirtualMachineSizes.new(location: 'location', service: @service)
end

def test_collection_attributes
assert_respond_to @virtual_machine_sizes, :location
end
end

0 comments on commit 45c77ce

Please sign in to comment.