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

setting up testing library to start writing tests

This commit is contained in:
Joshua Gross 2014-01-21 17:23:55 -05:00
parent 341ccf56f3
commit 7e61b90d85
3 changed files with 143 additions and 1 deletions

View file

@ -3,7 +3,7 @@ module Fog
class Rage4 class Rage4
class Real class Real
# Get the details for all domains in your account. # Get the lsit of all domains for your account.
# ==== Parameters # ==== Parameters
# #
# ==== Returns # ==== Returns

View file

@ -35,6 +35,9 @@ def dns_providers
:zone_attributes => { :zone_attributes => {
:email => 'fog@example.com' :email => 'fog@example.com'
} }
},
:rage4 => {
:mocked => false,
} }
} }
end end

View file

@ -0,0 +1,139 @@
Shindo.tests('Fog::DNS[:rage4] | DNS requests', ['rage4', 'dns']) do
@domain = ''
@domain_count = 0
tests("success") do
test("get current domain count") do
pending if Fog.mocking?
response = Fog::DNS[:rage4].list_domains()
debugger
if response.status == 200
@domain_count = response.body['list'].size
end
response.status == 200
end
test("create domain") do
pending if Fog.mocking?
domain = generate_unique_domain
response = Fog::DNS[:rage4].create_domain(domain)
if response.status == 201
@domain = response.body
end
response.status == 201
end
test("get domain by name") do
pending if Fog.mocking?
response = Fog::DNS[:rage4].get_domain(@domain["name"])
response.status == 200
end
test("create an A resource record") do
pending if Fog.mocking?
domain = @domain["name"]
name = "www"
type = "A"
data = "1.2.3.4"
response = Fog::DNS[:rage4].create_record(domain, name, type, data)
if response.status == 201
@record = response.body
end
response.status == 201
end
test("create a MX record") do
pending if Fog.mocking?
domain = @domain["name"]
name = ""
type = "MX"
data = "10 mail.#{domain}"
options = { :ttl => 60 }
response = Fog::DNS[:rage4].create_record(domain, name, type, data, options)
response.status == 201
end
test("update a record") do
pending if Fog.mocking?
domain = @domain["name"]
record_id = @record["id"]
options = {:name => '', :type => 'A', :data => "2.3.4.5", :ttl => 600}
response = Fog::DNS[:rage4].update_record(domain, record_id, options)
response.status == 200
end
test("get record - check ip/ttl") do
pending if Fog.mocking?
response = Fog::DNS[:rage4].get_record(@domain["name"], @record['id'])
record = response.body
result = false
if response.status == 200 && record['data'] == '2.3.4.5' && record['ttl'] == 600
result = true
end
result
end
test("list records") do
pending if Fog.mocking?
response = Fog::DNS[:rage4].list_records(@domain["name"])
if response.status == 200
@records = response.body
end
(response.status == 200) and (response.body.size == 2)
end
test("delete records") do
pending if Fog.mocking?
domain = @domain["name"]
result = true
@records.each do |record|
response = Fog::DNS[:rage4].delete_record(domain, record["id"])
if(response.status != 200)
result = false
break
end
end
result
end
test("delete domain") do
pending if Fog.mocking?
#puts "Rage4 - Sleeping for 10 seconds, otherwise test fails because DNS Made Easy queues requests, it still might fail if DNS Made Easy is busy! MOCK IT!"
#puts "THIS MOST LIKELY WILL FAIL ON LIVE because it can take while for DNS Made Easy to create a domain/zone, changing the host to api.sandbox.rage4.com should make it work"
#sleep 10
response = Fog::DNS[:rage4].delete_domain(@domain["name"])
response.status == 200
end
end
tests( 'failure') do
end
end