1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/tests/hp/requests/dns/records_tests.rb

64 lines
No EOL
2.1 KiB
Ruby

Shindo.tests("HP::DNS | record requests", ['hp', 'dns', 'record']) do
@record_format = {
'id' => String,
'name' => String,
'type' => String,
'domain_id' => String,
'ttl' => Integer,
'data' => String,
'priority' => Integer,
'created_at' => String,
'updated_at' => String
}
tests('success') do
@domain_name = 'www.fogtest.com.'
@email = 'test@fogtest.com'
@domain_id = HP[:dns].create_domain(@domain_name, @email).body['id']
@record_name = 'www.fogtest.com.'
@record_data = '15.185.172.152'
tests("#create_record(#{@domain_id}, #{@record_name}, 'A', #{@record_data}, 1)").formats(@record_format) do
data = HP[:dns].create_record(@domain_id, @record_name, 'A', @record_data, 1).body
@record_id = data['id']
data
end
tests("#list_records_in_a_domain(#{@domain_id})").formats({'records' => [@record_format]}) do
HP[:dns].list_records_in_a_domain(@domain_id).body
end
tests("#get_record(#{@domain_id}, #{@record_id})").formats(@record_format) do
HP[:dns].get_record(@domain_id, @record_id).body
end
tests("#update_record(#{@domain_id}, #{@record_id}, {:email => 'updated@fogtest.com'})").formats(@record_format) do
HP[:dns].update_record(@domain_id, @record_id, {:email => 'updated@fogtest.com'}).body
end
tests("#delete_record(#{@domain_id}, #{@record_id})").succeeds do
HP[:dns].delete_record(@domain_id, @record_id)
end
HP[:dns].delete_domain(@domain_id)
end
tests('failure') do
tests("#get_record(#{@domain_id}, 'invalid_record')").raises(Fog::HP::DNS::NotFound) do
HP[:dns].get_record(@domain_id, 'invalid_record')
end
tests("#update_record(#{@domain_id}, 'invalid_record', {:email => 'updated@fogtest.com'})").raises(Fog::HP::DNS::NotFound) do
HP[:dns].update_record(@domain_id, 'invalid_record', {:email => 'updated@fogtest.com'})
end
tests("#delete_record(#{@domain_id}, 'invalid_record')").raises(Fog::HP::DNS::NotFound) do
HP[:dns].delete_record(@domain_id, 'invalid_record')
end
end
end