1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

remove examples as they are not that helpful or well supported

This commit is contained in:
geemus 2012-02-27 16:57:57 -06:00
parent 7306dfe159
commit a32d3132f0
4 changed files with 2 additions and 355 deletions

View file

@ -55,14 +55,8 @@ namespace :test do
end end
end end
task :examples do task :test do
sh("export FOG_MOCK=false && bundle exec shindont examples") Rake::Task[:mock_tests].invoke && Rake::Task[:real_tests].invoke
# some don't provide mocks so we'll leave this out for now
# sh("export FOG_MOCK=true && bundle exec shindont examples")
end
task :test do # => :examples do
Rake::Task[:mock_tests].invoke && Rake::Task[:examples].invoke && Rake::Task[:real_tests].invoke
end end
def tests(mocked) def tests(mocked)

View file

@ -1,83 +0,0 @@
require 'rubygems'
require 'shindo'
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require File.join(File.dirname(__FILE__), '..', 'tests', 'helper')
Shindo.tests('compute examples', 'compute') do
# iterate over all the providers
Fog.providers.values.each do |provider|
# FIXME: implement expected shared compute stuff for these providers as well
next if ['Bluebox', 'Brightbox', 'Ecloud', 'GoGrid', 'Linode', 'NewServers', 'Ninefold', 'Slicehost', 'StormOnDemand', 'VirtualBox', 'Voxel'].include?(provider)
provider = eval(provider) # convert from string to object
# skip if provider does not have compute
next unless provider.respond_to?(:services) && provider.services.include?(:compute)
tests(provider, provider.to_s.downcase) do
# use shortcuts to instantiate connection
@compute = Fog::Compute.new(:provider => provider.to_s)
# create a server
tests('@server = @compute.servers.bootstrap').succeeds do
@server = @compute.servers.bootstrap
end
# list servers
tests('@servers = @compute.servers').succeeds do
@servers = @compute.servers
end
# get a server
tests('@compute.servers.get(@server.identity)').succeeds do
@compute.servers.get(@server.identity)
end
# ssh to a server
tests('@server.ssh("pwd")').succeeds do
@server.ssh('pwd')
end
# scp a file to a server
lorem_path = File.join([File.dirname(__FILE__), '..', 'tests', 'lorem.txt'])
tests("@server.scp_upload('#{lorem_path}', 'lorem.txt')").succeeds do
@server.scp_upload(lorem_path, 'lorem.txt')
end
# scp a file from a server
tests("@server.scp_download('lorem.txt', '/tmp/lorem.txt)").succeeds do
@server.scp_download('lorem.txt', '/tmp/lorem.txt')
end
File.delete('/tmp/lorem.txt')
# scp a directory to a server
Dir.mkdir('/tmp/lorem')
file = ::File.new('/tmp/lorem/lorem.txt', 'w')
file.write(File.read(lorem_path))
tests("@server.scp_upload('/tmp/lorem', '/tmp', :recursive => true)").succeeds do
@server.scp_upload('/tmp/lorem', '/tmp', :recursive => true)
end
File.delete('/tmp/lorem/lorem.txt')
Dir.rmdir('/tmp/lorem')
# scp a directory from a server
tests("@server.scp_download('/tmp/lorem', '/tmp', :recursive => true)").succeeds do
@server.scp_download('/tmp/lorem', '/tmp', :recursive => true)
end
File.delete('/tmp/lorem/lorem.txt')
Dir.rmdir('/tmp/lorem')
# destroy the server
tests('@server.destroy').succeeds do
@server.destroy
end
end
end
end

View file

@ -1,78 +0,0 @@
require 'rubygems'
require 'shindo'
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require File.join(File.dirname(__FILE__), '..', 'tests', 'helper')
Shindo.tests('dns examples', 'dns') do
# iterate over all the providers
Fog.providers.values.each do |provider|
provider = eval(provider) # convert from string to object
# skip if provider does not have storage
next unless provider.respond_to?(:services) && provider.services.include?(:dns)
tests(provider, provider.to_s.downcase) do
# use shortcuts to instantiate connection
@dns = Fog::DNS.new(:provider => provider.to_s)
# create a zone
# domain should be the hostname
# email is only required for linode, but included for consistency
tests('@zone = @dns.zones.create').succeeds do
@zone = @dns.zones.create(
:domain => 'fogdnsexamples.com',
:email => 'tests@fogdnsexamples.com'
)
end
# create a record in the zone
# ip is the address to route to
# name is the name for the record
# type is the type of record to create
tests('@record = @zone.records.create').succeeds do
@record = @zone.records.create(
:value => '1.2.3.4',
:name => 'www.fogdnsexamples.com',
:type => 'A'
)
end
# list zones
tests('@zones = @dns.zones').succeeds do
@zones = @dns.zones
end
# get a zone
tests('@dns.zones.get(@zone.identity)').succeeds do
@dns.zones.get(@zone.identity)
end
# list records
tests('@records = @zone.records').succeeds do
@records = @zone.records
end
# get a record
tests('@zone.records.get(@record.identity)').succeeds do
@zone.records.get(@record.identity)
end
# destroy the record
tests('@record.destroy').succeeds do
@record.destroy
end
# destroy the zone
tests('@zone.destroy').succeeds do
@zone.destroy
end
end
end
end

View file

@ -1,186 +0,0 @@
require 'rubygems'
require 'shindo'
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require File.join(File.dirname(__FILE__), '..', 'tests', 'helper')
Shindo.tests('storage examples', 'storage') do
# iterate over all the providers
Fog.providers.values.each do |provider|
provider = eval(provider) # convert from string to object
# skip if provider does not have storage
next unless provider.respond_to?(:services) && provider.services.include?(:storage)
tests(provider, provider.to_s.downcase) do
# use shortcuts to instantiate connection
@storage = Fog::Storage.new(:provider => provider.to_s)
# for compatibility public is simply true or false
[false, true].each do |publicity|
tests(":public => #{publicity}") do
# create a directory
# key should be a unique string
# public should be a boolean
tests('@directory = @storage.directories.create').succeeds do
@directory = @storage.directories.create(
:key => "fogstoragedirectory#{Time.now.to_i}",
:public => publicity
)
end
# list directories
tests('@directories = @storage.directories').succeeds do
@directories = @storage.directories
end
# get a directory
tests('@storage.directories.get(@directory.identity)').succeeds do
@storage.directories.get(@directory.identity)
end
# create a file in the directory
# key can be any string
# body can be a string or a file as File.open(path)
# public should be a boolean and match the directory
tests('@file = @directory.files.create').succeeds do
@file = @directory.files.create(
:body => 'fog_storage_object_body',
:key => 'fogstorageobject',
:public => publicity
)
end
# list files
tests('@files = @directory.files').succeeds do
@files = @directory.files
end
# get a file
tests('@directory.files.get(@file.identity)').succeeds do
@directory.files.get(@file.identity)
end
# test the publicity of files
# Local is unable to inherently serve files, so we can skip it
unless provider == Local
# if the file is public it should have a url
test('!!@file.public_url == publicity') do
pending if Fog.mocking?
!!@file.public_url == publicity
end
# if it is public ensure that public url is usable
if publicity
tests('Excon.get(@file.public_url).body').returns('fog_storage_object_body') do
pending if Fog.mocking?
Excon.get(@file.public_url).body
end
end
end
tests('@file.copy').succeeds do
@file.copy(@directory.key, 'fogstorageobject2')
end
tests('@copy = @directory.files.get(fogstorageobject2)').succeeds do
@copy = @directory.files.get('fogstorageobject2')
end
tests('@copy.body == @file.body').succeeds do
@copy.body == @file.body
end
tests('@copy.destroy').succeeds do
@copy.destroy
end
# destroy the file
tests('@file.destroy').succeeds do
@file.destroy
end
# destroy the directory
tests('@directory.destroy').succeeds do
@directory.destroy
end
end
end
tests(':key => \"fog/storageobject\"') do
# create a directory
# key should be a unique string
# public should be a boolean
tests('@directory = @storage.directories.create').succeeds do
@directory = @storage.directories.create(
:key => "fogstoragedirectory#{Time.now.to_i}",
:public => true
)
end
# list directories
tests('@directories = @storage.directories').succeeds do
@directories = @storage.directories
end
# get a directory
tests('@storage.directories.get(@directory.identity)').succeeds do
@storage.directories.get(@directory.identity)
end
# create a file in the directory
# key can be any string
# body can be a string or a file as File.open(path)
# public should be a boolean and match the directory
tests('@file = @directory.files.create').succeeds do
@file = @directory.files.create(
:body => 'fog_storage_object_body',
:key => 'fog/storageobject',
:public => true
)
end
# list files
tests('@files = @directory.files').succeeds do
@files = @directory.files
end
# get a file
tests('@directory.files.get(@file.identity)').succeeds do
@directory.files.get(@file.identity)
end
# test the publicity of files
# Local is unable to inherently serve files, so we can skip it
unless provider == Local
tests('Excon.get(@file.public_url).body').returns('fog_storage_object_body') do
pending if Fog.mocking?
Excon.get(@file.public_url).body
end
end
# destroy the file
tests('@file.destroy').succeeds do
@file.destroy
end
# destroy the directory
tests('@directory.destroy').succeeds do
@directory.destroy
end
end
end
end
end