mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[local] tests, setup to be shared with other storage providers
This commit is contained in:
parent
c822f8bd77
commit
898435a793
9 changed files with 166 additions and 0 deletions
|
@ -3,6 +3,10 @@ require 'fog/core/bin'
|
|||
Fog.bin = true
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'model_helper'))
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'storage', 'directory_tests'))
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'storage', 'directories_tests'))
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'storage', 'file_tests'))
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), 'helpers', 'storage', 'files_tests'))
|
||||
|
||||
if ENV["FOG_MOCK"] == "true"
|
||||
Fog.mock!
|
||||
|
|
39
tests/helpers/storage/directories_tests.rb
Normal file
39
tests/helpers/storage/directories_tests.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
def directories_tests(connection, mocks_implemented = true)
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#new(:key => 'fogdirectoriestests')").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory = connection.directories.new(:key => 'fogdirectoriestests')
|
||||
end
|
||||
|
||||
tests("#create(:key => 'fogdirectoriestests')").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory = connection.directories.create(:key => 'fogdirectoriestests')
|
||||
end
|
||||
|
||||
tests("#all").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
connection.directories.all
|
||||
end
|
||||
|
||||
tests("#get('fogdirectoriestests')").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
connection.directories.get('fogdirectoriestests')
|
||||
end
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@directory.destroy
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get('fognondirectory')").returns(nil) do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
connection.directories.get('fognondirectory')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
24
tests/helpers/storage/directory_tests.rb
Normal file
24
tests/helpers/storage/directory_tests.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
def directory_tests(connection, mocks_implemented = true)
|
||||
|
||||
tests('success') do
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@directory = connection.directories.new(:key => 'fogdirectorytests')
|
||||
end
|
||||
|
||||
tests("#save").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory.save
|
||||
end
|
||||
|
||||
tests("#destroy").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory.destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
end
|
||||
|
||||
end
|
32
tests/helpers/storage/file_tests.rb
Normal file
32
tests/helpers/storage/file_tests.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
def file_tests(connection, mocks_implemented = true)
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@directory = connection.directories.create(:key => 'fogfilestests')
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@file = @directory.files.new(:key => 'fog_file_tests', :body => lorem_file)
|
||||
end
|
||||
|
||||
tests("#save").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@file.save
|
||||
end
|
||||
|
||||
tests("#destroy").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@file.destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
end
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@directory.destroy
|
||||
end
|
||||
|
||||
end
|
47
tests/helpers/storage/files_tests.rb
Normal file
47
tests/helpers/storage/files_tests.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
def files_tests(connection, mocks_implemented = true)
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@directory = connection.directories.create(:key => 'fogfilestests')
|
||||
end
|
||||
|
||||
tests('success') do
|
||||
|
||||
tests("#new(:key => 'fog_files_tests', :body => lorem_file)").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory.files.new(:key => 'fog_files_tests', :body => lorem_file)
|
||||
end
|
||||
|
||||
tests("#create(:key => 'fog_files_tests', :body => lorem_file)").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@file = @directory.files.create(:key => 'fog_files_tests', :body => lorem_file)
|
||||
end
|
||||
|
||||
tests("#all").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory.files.all
|
||||
end
|
||||
|
||||
tests("#get('fog_files_tests')").succeeds do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory.files.get('fog_files_tests')
|
||||
end
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@file.destroy
|
||||
end
|
||||
end
|
||||
|
||||
tests('failure') do
|
||||
|
||||
tests("#get('fog_non_file')").returns(nil) do
|
||||
pending if Fog.mocking? && !mocks_implemented
|
||||
@directory.files.get('fog_non_file')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if !Fog.mocking? || mocks_implemented
|
||||
@directory.destroy
|
||||
end
|
||||
|
||||
end
|
5
tests/local/models/storage/directories_tests.rb
Normal file
5
tests/local/models/storage/directories_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Local::Storage | directories collection', ['local']) do
|
||||
|
||||
directories_tests(Local[:storage], false)
|
||||
|
||||
end
|
5
tests/local/models/storage/directory_tests.rb
Normal file
5
tests/local/models/storage/directory_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Local::Storage | directory model', ['local']) do
|
||||
|
||||
directory_tests(Local[:storage], false)
|
||||
|
||||
end
|
5
tests/local/models/storage/file_tests.rb
Normal file
5
tests/local/models/storage/file_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Local::Storage | file model', ['local']) do
|
||||
|
||||
file_tests(Local[:storage], false)
|
||||
|
||||
end
|
5
tests/local/models/storage/files_tests.rb
Normal file
5
tests/local/models/storage/files_tests.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
Shindo.tests('Local::Storage | files collection', ['local']) do
|
||||
|
||||
files_tests(Local[:storage], false)
|
||||
|
||||
end
|
Loading…
Add table
Reference in a new issue