mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[xenserver] StorageRepository.save should use sane defaults
- Added required tests - Minor StorageRepository tests refactoring
This commit is contained in:
parent
9db7f34aa8
commit
5b6ca0b98b
2 changed files with 47 additions and 20 deletions
|
@ -63,12 +63,12 @@ module Fog
|
||||||
connection.create_sr( host.reference,
|
connection.create_sr( host.reference,
|
||||||
name,
|
name,
|
||||||
type,
|
type,
|
||||||
description,
|
description || '',
|
||||||
device_config,
|
device_config || {},
|
||||||
physical_size,
|
physical_size || '0',
|
||||||
content_type,
|
content_type || 'user',
|
||||||
shared || false,
|
shared || false,
|
||||||
sm_config),
|
sm_config || {}),
|
||||||
'SR'
|
'SR'
|
||||||
)
|
)
|
||||||
merge_attributes attr
|
merge_attributes attr
|
||||||
|
|
|
@ -2,6 +2,7 @@ Shindo.tests('Fog::Compute[:xenserver] | StorageRepository model', ['xenserver']
|
||||||
|
|
||||||
storage_repositories = Fog::Compute[:xenserver].storage_repositories
|
storage_repositories = Fog::Compute[:xenserver].storage_repositories
|
||||||
storage_repository = storage_repositories.first
|
storage_repository = storage_repositories.first
|
||||||
|
conn = Fog::Compute[:xenserver]
|
||||||
|
|
||||||
tests('The StorageRepository model should') do
|
tests('The StorageRepository model should') do
|
||||||
tests('have the action') do
|
tests('have the action') do
|
||||||
|
@ -65,23 +66,49 @@ Shindo.tests('Fog::Compute[:xenserver] | StorageRepository model', ['xenserver']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test('#save') do
|
tests('#save should') do
|
||||||
conn = Fog::Compute[:xenserver]
|
sr = nil
|
||||||
|
test('save with required attributes') do
|
||||||
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
||||||
:host => conn.hosts.first,
|
:host => conn.hosts.first,
|
||||||
:type => 'ext',
|
:type => 'ext',
|
||||||
:content_type => 'local SR',
|
:device_config => { :device => '/dev/sdb' }
|
||||||
|
!(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
||||||
|
end
|
||||||
|
# Cleanup
|
||||||
|
sr.pbds.each { |pbd| pbd.unplug }
|
||||||
|
sr.destroy
|
||||||
|
test('save with additional attributes') do
|
||||||
|
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
||||||
|
:host => conn.hosts.first,
|
||||||
|
:type => 'ext',
|
||||||
|
:content_type => 'user',
|
||||||
:device_config => { :device => '/dev/sdb' },
|
:device_config => { :device => '/dev/sdb' },
|
||||||
:shared => false
|
:shared => false
|
||||||
!(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
!(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
||||||
end
|
end
|
||||||
|
# Cleanup
|
||||||
|
sr.pbds.each { |pbd| pbd.unplug }
|
||||||
|
sr.destroy
|
||||||
|
test('return sane defaults') do
|
||||||
|
sr = conn.storage_repositories.create :name => 'FOG TEST SR',
|
||||||
|
:host => conn.hosts.first,
|
||||||
|
:type => 'ext',
|
||||||
|
:device_config => { :device => '/dev/sdb' }
|
||||||
|
sr.reload
|
||||||
|
(sr.content_type == 'user') and \
|
||||||
|
(sr.shared == false) and (sr.sm_config.is_a? Hash) and \
|
||||||
|
(sr.description == '')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
test('#destroy') do
|
tests('#destroy should') do
|
||||||
conn = Fog::Compute[:xenserver]
|
test('destroy existing FOG TEST SR') do
|
||||||
sr = (conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' })
|
sr = (conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' })
|
||||||
sr.pbds.each { |pbd| pbd.unplug }
|
sr.pbds.each { |pbd| pbd.unplug }
|
||||||
sr.destroy
|
sr.destroy
|
||||||
(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
(conn.storage_repositories.find { |sr| sr.name == 'FOG TEST SR' }).nil?
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue