mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add model tests for storage service.
This commit is contained in:
parent
fa3343fd67
commit
3cb5dee0f9
4 changed files with 153 additions and 0 deletions
tests/hp/models/storage
17
tests/hp/models/storage/directories_tests.rb
Normal file
17
tests/hp/models/storage/directories_tests.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
Shindo.tests('Fog::Storage[:hp] | directories', ['hp', 'storage']) do
|
||||
|
||||
collection_tests(Fog::Storage[:hp].directories, {:key => "fogdirtests"}, true)
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#head('fogdirtests')").succeeds do
|
||||
Fog::Storage[:hp].directories.head('fogdirtests')
|
||||
end
|
||||
|
||||
tests("#get('fogdirtests')").succeeds do
|
||||
Fog::Storage[:hp].directories.get('fogdirtests')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
50
tests/hp/models/storage/directory_tests.rb
Normal file
50
tests/hp/models/storage/directory_tests.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
Shindo.tests('Fog::Storage[:hp] | directory', ['hp', 'storage']) do
|
||||
|
||||
model_tests(Fog::Storage[:hp].directories, {:key => "fogdirtests"}, true) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#acl='public-read'").succeeds do
|
||||
@instance.acl = 'public-read'
|
||||
tests("public?").returns(true) do
|
||||
@instance.public?
|
||||
end
|
||||
end
|
||||
|
||||
@instance.files.create(:key => 'sample.txt', :body => lorem_file)
|
||||
tests("#files").succeeds do
|
||||
@instance.files
|
||||
end
|
||||
@instance.files.get('sample.txt').destroy
|
||||
|
||||
tests("#cdn_enable=(true)").succeeds do
|
||||
@instance.cdn_enable=(true)
|
||||
tests("cdn_enabled?").returns(true) do
|
||||
pending if Fog.mocking?
|
||||
@instance.cdn_enable?
|
||||
end
|
||||
end
|
||||
|
||||
tests("#cdn_public_url").succeeds do
|
||||
pending if Fog.mocking?
|
||||
@instance.cdn_public_url
|
||||
end
|
||||
|
||||
tests("#cdn_public_ssl_url").succeeds do
|
||||
pending if Fog.mocking?
|
||||
@instance.cdn_public_ssl_url
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#acl='invalid-acl'").raises(ArgumentError) do
|
||||
@instance.acl = 'invalid-acl'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
44
tests/hp/models/storage/file_tests.rb
Normal file
44
tests/hp/models/storage/file_tests.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
Shindo.tests('Fog::Storage[:hp] | directory', ['hp', 'storage']) do
|
||||
|
||||
file_attributes = {
|
||||
:key => 'fog_file_tests',
|
||||
:body => lorem_file,
|
||||
:public => true
|
||||
}
|
||||
|
||||
directory_attributes = {
|
||||
:key => 'fogfilestests'
|
||||
}
|
||||
|
||||
@directory = Fog::Storage[:hp].directories.create(directory_attributes)
|
||||
|
||||
model_tests(@directory.files, file_attributes, true) do
|
||||
|
||||
@file = @directory.files.get('fog_file_tests')
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#directory").returns(@directory.key) do
|
||||
@file.directory.key
|
||||
end
|
||||
|
||||
tests("#cdn_public_url").succeeds do
|
||||
pending if Fog.mocking?
|
||||
@file.cdn_public_url
|
||||
end
|
||||
|
||||
tests("#cdn_public_ssl_url").succeeds do
|
||||
pending if Fog.mocking?
|
||||
@file.cdn_public_ssl_url
|
||||
end
|
||||
|
||||
tests("#temp_signed_url(60, 'GET')").succeeds do
|
||||
@file.temp_signed_url(60, 'GET')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@directory.destroy
|
||||
|
||||
end
|
42
tests/hp/models/storage/files_tests.rb
Normal file
42
tests/hp/models/storage/files_tests.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
Shindo.tests('Fog::Storage[:hp] | files', ['hp', 'storage']) do
|
||||
|
||||
file_attributes = {
|
||||
:key => 'fog_files_tests',
|
||||
:body => lorem_file
|
||||
}
|
||||
|
||||
directory_attributes = {
|
||||
:key => 'fogfilestests'
|
||||
}
|
||||
|
||||
@directory = Fog::Storage[:hp].directories.create(directory_attributes)
|
||||
|
||||
collection_tests(@directory.files, file_attributes, true) do
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#get_url('#{@directory.key}')").succeeds do
|
||||
@directory.files.get_url("#{@directory.key}")
|
||||
end
|
||||
|
||||
tests("#get_cdn_url('#{@directory.key}')").succeeds do
|
||||
pending if Fog.mocking?
|
||||
@directory.files.get_cdn_url("#{@directory.key}")
|
||||
end
|
||||
|
||||
tests("#get_cdn_ssl_url('#{@directory.key}')").succeeds do
|
||||
pending if Fog.mocking?
|
||||
@directory.files.get_cdn_ssl_url("#{@directory.key}")
|
||||
end
|
||||
|
||||
tests("#head('#{@directory.key}')").succeeds do
|
||||
@directory.files.head("#{@directory.key}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@directory.destroy
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue