Sha256: a61dabffba1b6be3c6c4e67f56a861e4183a93ab99ee9ad4314f8fcf871b87bb

Contents?: true

Size: 1.98 KB

Versions: 2

Compression:

Stored size: 1.98 KB

Contents

require 'rubygems'
require 'require_relative' if RUBY_VERSION < '1.9'

require_relative 'common'

describe 'FgcpDriver StorageVolumes' do

  before do
    @driver = Deltacloud::new(:fgcp, credentials)
    VCR.insert_cassette __name__
  end

  after do
    VCR.eject_cassette
  end

  it 'must throw error when wrong credentials' do
    Proc.new do
      @driver.backend.storage_volumes(OpenStruct.new(:user => 'unknown', :password => 'wrong'))
    end.must_raise Deltacloud::Exceptions::AuthenticationFailure, 'Authentication Failure'
  end

  it 'must return list of storage_volumes' do
    @driver.storage_volumes.wont_be_empty
    @driver.storage_volumes.first.must_be_kind_of Deltacloud::StorageVolume
  end

  it 'must allow to filter storage_volumes' do
    storage_volumes = @driver.storage_volumes(:id => 'UZXC0GRT-ZG8ZJCJ07-D-0039')
    storage_volumes.wont_be_empty
    storage_volumes.must_be_kind_of Array
    storage_volumes.size.must_equal 1
    storage_volumes.first.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-D-0039'
    @driver.storage_volumes(:id => 'unknown').must_be_empty
  end

  it 'must allow to retrieve single storage_volume' do
    storage_volume = @driver.storage_volume(:id => 'UZXC0GRT-ZG8ZJCJ07-D-0039')
    storage_volume.wont_be_nil
    storage_volume.must_be_kind_of Deltacloud::StorageVolume
    storage_volume.id.must_equal 'UZXC0GRT-ZG8ZJCJ07-D-0039'
    @driver.storage_volume(:id => 'unknown').must_be_nil
  end

  it 'must allow to create the storage volume' do
    volume = @driver.create_storage_volume(:name => 'Test Volume', :capacity => '2')
    volume.must_be_kind_of Deltacloud::StorageVolume
    volume.name.must_equal 'Test Volume'
    volume.capacity.must_equal '10.0' # note that it's rounded up to a multiple of ten
    volume2 = @driver.storage_volume(:id => volume.id)
    volume2.wont_be_nil
    volume2.must_be_kind_of Deltacloud::StorageVolume
    volume2.id.must_equal volume.id
    volume2.name.must_equal volume.name
    volume2.capacity.must_equal volume.capacity
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
deltacloud-core-1.1.3 tests/drivers/fgcp/storage_volumes_test.rb
deltacloud-core-1.1.2 tests/drivers/fgcp/storage_volumes_test.rb