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

79 lines
2 KiB
Ruby
Raw Normal View History

2011-01-04 19:49:35 -05:00
require 'rubygems'
require 'shindo'
require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require File.join(File.dirname(__FILE__), '..', 'tests', 'helper')
2011-06-08 20:51:45 -04:00
Shindo.tests('dns examples', 'dns') do
2011-01-04 19:49:35 -05:00
# iterate over all the providers
2011-12-19 15:23:32 -05:00
Fog.providers.values.each do |provider|
2011-01-04 19:49:35 -05:00
2011-02-11 17:36:48 -05:00
provider = eval(provider) # convert from string to object
2011-01-04 19:49:35 -05:00
# 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'
2011-01-04 19:49:35 -05:00
)
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