Sha256: 0ea64c73fd599cbb115d82d6f7c422e8b62462fa0f4fc377dd9ce4b2ab74e00a

Contents?: true

Size: 1.93 KB

Versions: 6

Compression:

Stored size: 1.93 KB

Contents

Shindo.tests('Fog::Compute[:libvirt] | server model', ['libvirt']) do

  servers = Fog::Compute[:libvirt].servers
  server = servers.all.select{|v| v.name =~ /^fog/}.last

  tests('The server model should') do
    tests('have the action') do
      test('autostart') { server.respond_to? 'autostart' }
      test('update_autostart') { server.respond_to? 'update_autostart' }
      test('reload') { server.respond_to? 'reload' }
      %w{ start stop destroy reboot suspend }.each do |action|
        test(action) { server.respond_to? action }
      end
      %w{ start reboot suspend stop destroy}.each do |action|
        test("#{action} returns successfully") {
          begin
            server.send(action.to_sym)
          rescue Libvirt::Error
            #libvirt error is acceptable for the above actions.
            true
          end
        }
      end
    end
    tests('have an ip_address action that') do
      test('returns the latest IP address lease') { server.public_ip_address() == '1.2.5.6' }
    end
    tests('have attributes') do
      model_attribute_hash = server.attributes
      attributes = [ :id,
        :cpus,
        :cputime,
        :os_type,
        :memory_size,
        :max_memory_size,
        :name,
        :arch,
        :persistent,
        :domain_type,
        :uuid,
        :autostart,
        :display,
        :nics,
        :volumes,
        :active,
        :boot_order,
        :hugepages,
        :state]
      tests("The server model should respond to") do
        attributes.each do |attribute|
          test("#{attribute}") { server.respond_to? attribute }
        end
      end
      tests("The attributes hash should have key") do
        attributes.delete(:volumes)
        attributes.each do |attribute|
          test("#{attribute}") { model_attribute_hash.key? attribute }
        end
      end
    end
    test('be a kind of Fog::Libvirt::Compute::Server') { server.kind_of? Fog::Libvirt::Compute::Server }
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
fog-libvirt-0.11.0 tests/libvirt/models/compute/server_tests.rb
fog-libvirt-0.10.1 tests/libvirt/models/compute/server_tests.rb
fog-libvirt-0.10.0 tests/libvirt/models/compute/server_tests.rb
fog-libvirt-csem-0.9.0 tests/libvirt/models/compute/server_tests.rb
fog-libvirt-0.9.0 tests/libvirt/models/compute/server_tests.rb
fog-libvirt-0.8.0 tests/libvirt/models/compute/server_tests.rb