Sha256: 837c90f334eb7087ba8e448783021963cbe026f1bad70cc58f86af04f58b551e

Contents?: true

Size: 2 KB

Versions: 9

Compression:

Stored size: 2 KB

Contents

require 'rubygems'
require 'shindo'

require File.join(File.dirname(__FILE__), '..', 'lib', 'fog')
require File.join(File.dirname(__FILE__), '..', 'tests', 'helper')

Shindo.tests('dns tests', 'dns') do

  # iterate over all the providers
  Fog.providers.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(
          :ip => '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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-0.8.2 examples/dns_tests.rb
fog-0.8.1 examples/dns_tests.rb
fog-0.8.0 examples/dns_tests.rb
fog-0.7.2 examples/dns_tests.rb
fog-0.7.1 examples/dns_tests.rb
fog-0.7.0 examples/dns_tests.rb
fog-0.6.0 examples/dns_tests.rb
fog-0.5.3 examples/dns_tests.rb
fog-0.5.2 examples/dns_tests.rb