forked from AppScale/gts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestDjinn.rb
executable file
·32 lines (28 loc) · 1.1 KB
/
testDjinn.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/ruby -w
require 'test/unit'
require 'helperfunctions'
require 'djinn'
class TestDjinn < Test::Unit::TestCase
def test_helper_local_ip
ip_msg = "Local IP must match the regex format for IP addresses"
local_ip_result = HelperFunctions.local_ip
assert(local_ip_result =~ /\d+\.\d+\.\d+\.\d+/, ip_msg)
end
def test_spawn_vms
begin
spawn_vms_result = HelperFunctions.spawn_vms
rescue Exception => except
spawn_vms_result = except
end
if spawn_vms_result.class == Hash
assert(!spawn_vms_result.empty?, "Instance hash shouldn't be empty")
terminate_result = HelperFunctions.terminate_vms(spawn_vms_result)
assert_nil(terminate_result)
elsif spawn_vms_result.class == VMException
assert(spawn_vms_result.message == "No instance was able to get a public IP address", "An unexpected virtual machine exception was thrown, with the message: #{spawn_vms_result.message}")
else
HelperFunctions.terminate_all_vms
flunk("Return value should be either a Hash or an Exception, not a #{spawn_vms_result.class}")
end
end
end