fog 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/Gemfile +1 -1
  2. data/Gemfile.lock +4 -4
  3. data/benchs/fog_vs.rb +8 -37
  4. data/fog.gemspec +6 -12
  5. data/lib/fog.rb +1 -1
  6. data/lib/fog/aws/requests/ec2/delete_key_pair.rb +4 -3
  7. data/lib/fog/aws/requests/ec2/describe_volumes.rb +2 -2
  8. data/lib/fog/aws/s3.rb +8 -4
  9. data/lib/fog/rackspace/models/servers/image.rb +5 -0
  10. data/tests/aws/helper.rb +33 -0
  11. data/tests/aws/requests/ec2/address_tests.rb +40 -47
  12. data/tests/aws/requests/ec2/availability_zone_tests.rb +23 -0
  13. data/tests/aws/requests/ec2/key_pair_tests.rb +44 -0
  14. data/tests/aws/requests/ec2/region_tests.rb +22 -0
  15. data/tests/aws/requests/ec2/security_group_tests.rb +112 -0
  16. data/tests/aws/requests/ec2/snapshot_tests.rb +14 -21
  17. data/tests/aws/requests/ec2/volume_tests.rb +26 -40
  18. data/tests/helper.rb +50 -35
  19. data/tests/rackspace/helper.rb +2 -0
  20. data/tests/rackspace/requests/servers/create_image_tests.rb +11 -13
  21. data/tests/rackspace/requests/servers/create_server_tests.rb +9 -11
  22. data/tests/rackspace/requests/servers/delete_image_tests.rb +9 -15
  23. data/tests/rackspace/requests/servers/delete_server_tests.rb +6 -10
  24. data/tests/rackspace/requests/servers/get_flavor_details_tests.rb +4 -10
  25. data/tests/rackspace/requests/servers/get_image_details_tests.rb +4 -10
  26. data/tests/rackspace/requests/servers/get_server_details_tests.rb +7 -14
  27. data/tests/rackspace/requests/servers/list_addresses_tests.rb +7 -14
  28. data/tests/rackspace/requests/servers/list_flavors_detail_tests.rb +2 -6
  29. data/tests/rackspace/requests/servers/list_flavors_tests.rb +2 -6
  30. data/tests/rackspace/requests/servers/list_images_detail_tests.rb +2 -6
  31. data/tests/rackspace/requests/servers/list_images_tests.rb +2 -6
  32. data/tests/rackspace/requests/servers/list_private_addresses_tests.rb +7 -14
  33. data/tests/rackspace/requests/servers/list_public_addresses_tests.rb +7 -14
  34. data/tests/rackspace/requests/servers/list_servers_detail_tests.rb +5 -10
  35. data/tests/rackspace/requests/servers/list_servers_tests.rb +5 -10
  36. data/tests/rackspace/requests/servers/reboot_server_tests.rb +11 -19
  37. data/tests/rackspace/requests/servers/update_server_tests.rb +7 -14
  38. data/tests/slicehost/requests/create_slice_tests.rb +6 -11
  39. data/tests/slicehost/requests/delete_slice_tests.rb +4 -9
  40. data/tests/slicehost/requests/get_backups_tests.rb +2 -6
  41. data/tests/slicehost/requests/get_flavor_tests.rb +4 -10
  42. data/tests/slicehost/requests/get_flavors_tests.rb +2 -6
  43. data/tests/slicehost/requests/get_image_tests.rb +4 -10
  44. data/tests/slicehost/requests/get_images_tests.rb +2 -6
  45. data/tests/slicehost/requests/get_slice_tests.rb +7 -15
  46. data/tests/slicehost/requests/get_slices_tests.rb +2 -6
  47. data/tests/slicehost/requests/reboot_slice_tests.rb +8 -16
  48. metadata +7 -13
  49. data/spec/aws/requests/ec2/authorize_security_group_ingress_spec.rb +0 -36
  50. data/spec/aws/requests/ec2/create_key_pair_spec.rb +0 -36
  51. data/spec/aws/requests/ec2/create_security_group_spec.rb +0 -34
  52. data/spec/aws/requests/ec2/delete_key_pair_spec.rb +0 -21
  53. data/spec/aws/requests/ec2/delete_security_group_spec.rb +0 -26
  54. data/spec/aws/requests/ec2/describe_availability_zones_spec.rb +0 -23
  55. data/spec/aws/requests/ec2/describe_key_pairs_spec.rb +0 -42
  56. data/spec/aws/requests/ec2/describe_regions_spec.rb +0 -21
  57. data/spec/aws/requests/ec2/describe_security_groups_spec.rb +0 -51
  58. data/spec/aws/requests/ec2/revoke_security_group_ingress_spec.rb +0 -32
@@ -0,0 +1,22 @@
1
+ Shindo.tests('AWS::EC2 | region requests', ['aws']) do
2
+
3
+ tests('success') do
4
+
5
+ tests("#describe_regions").formats(AWS::EC2::Formats::REGIONS) do
6
+ AWS[:ec2].describe_regions.body
7
+ end
8
+
9
+ tests("#describe_regions('us-east-1')").formats(AWS::EC2::Formats::REGIONS) do
10
+ AWS[:ec2].describe_regions('us-east-1').body
11
+ end
12
+
13
+ end
14
+
15
+ tests('failure') do
16
+
17
+ tests("#describe_regions('not-a-region')").raises(Excon::Errors::BadRequest) do
18
+ AWS[:ec2].describe_regions('not-a-region')
19
+ end
20
+ end
21
+
22
+ end
@@ -0,0 +1,112 @@
1
+ Shindo.tests('AWS::EC2 | security group requests', ['aws']) do
2
+
3
+ @owner_id = AWS[:ec2].describe_security_groups('default').body['securityGroupInfo'].first['ownerId']
4
+
5
+ tests('success') do
6
+
7
+ tests("#create_security_group('fog_security_group', 'tests group')").formats(AWS::EC2::Formats::BASIC) do
8
+ AWS[:ec2].create_security_group('fog_security_group', 'tests group').body
9
+ end
10
+
11
+ tests("#authorize_security_group_ingress({'FromPort' => 80, 'GroupName' => 'fog_security_group', 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::EC2::Formats::BASIC) do
12
+ AWS[:ec2].authorize_security_group_ingress({
13
+ 'FromPort' => 80,
14
+ 'GroupName' => 'fog_security_group',
15
+ 'IpProtocol' => 'tcp',
16
+ 'ToPort' => 80,
17
+ }).body
18
+ end
19
+
20
+ tests("#authorize_security_group_ingress({'GroupName' => 'fog_security_group', 'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::EC2::Formats::BASIC) do
21
+ AWS[:ec2].authorize_security_group_ingress({
22
+ 'GroupName' => 'fog_security_group',
23
+ 'SourceSecurityGroupName' => 'fog_security_group',
24
+ 'SourceSecurityGroupOwnerId' => @owner_id
25
+ }).body
26
+ end
27
+
28
+ tests("#describe_security_groups").formats(AWS::EC2::Formats::SECURITY_GROUPS) do
29
+ AWS[:ec2].describe_security_groups.body
30
+ end
31
+
32
+ tests("#describe_security_groups('fog_security_group')").formats(AWS::EC2::Formats::SECURITY_GROUPS) do
33
+ AWS[:ec2].describe_security_groups('fog_security_group').body
34
+ end
35
+
36
+ tests("#revoke_security_group_ingress({'FromPort' => 80, 'GroupName' => 'fog_security_group', 'IpProtocol' => 'tcp', 'toPort' => 80})").formats(AWS::EC2::Formats::BASIC) do
37
+ AWS[:ec2].revoke_security_group_ingress({
38
+ 'FromPort' => 80,
39
+ 'GroupName' => 'fog_security_group',
40
+ 'IpProtocol' => 'tcp',
41
+ 'ToPort' => 80,
42
+ }).body
43
+ end
44
+
45
+ tests("#revoke_security_group_ingress({'GroupName' => 'fog_security_group', 'SourceSecurityGroupName' => 'fog_security_group', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").formats(AWS::EC2::Formats::BASIC) do
46
+ AWS[:ec2].revoke_security_group_ingress({
47
+ 'GroupName' => 'fog_security_group',
48
+ 'SourceSecurityGroupName' => 'fog_security_group',
49
+ 'SourceSecurityGroupOwnerId' => @owner_id
50
+ }).body
51
+ end
52
+
53
+ tests("#delete_security_group('fog_security_group')").formats(AWS::EC2::Formats::BASIC) do
54
+ AWS[:ec2].delete_security_group('fog_security_group').body
55
+ end
56
+
57
+ end
58
+ tests('failure') do
59
+
60
+ @security_group = AWS[:ec2].security_groups.create(:description => 'tests group', :name => 'fog_security_group')
61
+
62
+ tests("duplicate #create_security_group(#{@security_group.name}, #{@security_group.description})").raises(Excon::Errors::BadRequest) do
63
+ AWS[:ec2].create_security_group(@security_group.name, @security_group.description)
64
+ end
65
+
66
+ tests("#authorize_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Excon::Errors::BadRequest) do
67
+ AWS[:ec2].authorize_security_group_ingress({
68
+ 'FromPort' => 80,
69
+ 'GroupName' => 'not_a_group_name',
70
+ 'IpProtocol' => 'tcp',
71
+ 'ToPort' => 80,
72
+ })
73
+ end
74
+
75
+ tests("#authorize_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Excon::Errors::BadRequest) do
76
+ AWS[:ec2].authorize_security_group_ingress({
77
+ 'GroupName' => 'not_a_group_name',
78
+ 'SourceSecurityGroupName' => 'not_a_group_name',
79
+ 'SourceSecurityGroupOwnerId' => @owner_id
80
+ })
81
+ end
82
+
83
+ tests("#describe_security_group('not_a_group_name)").raises(Excon::Errors::BadRequest) do
84
+ AWS[:ec2].describe_security_groups('not_a_group_name')
85
+ end
86
+
87
+ tests("#revoke_security_group_ingress({'FromPort' => 80, 'GroupName' => 'not_a_group_name', 'IpProtocol' => 'tcp', 'toPort' => 80})").raises(Excon::Errors::BadRequest) do
88
+ AWS[:ec2].revoke_security_group_ingress({
89
+ 'FromPort' => 80,
90
+ 'GroupName' => 'not_a_group_name',
91
+ 'IpProtocol' => 'tcp',
92
+ 'ToPort' => 80,
93
+ })
94
+ end
95
+
96
+ tests("#revoke_security_group_ingress({'GroupName' => 'not_a_group_name', 'SourceSecurityGroupName' => 'not_a_group_name', 'SourceSecurityGroupOwnerId' => '#{@owner_id}'})").raises(Excon::Errors::BadRequest) do
97
+ AWS[:ec2].revoke_security_group_ingress({
98
+ 'GroupName' => 'not_a_group_name',
99
+ 'SourceSecurityGroupName' => 'not_a_group_name',
100
+ 'SourceSecurityGroupOwnerId' => @owner_id
101
+ })
102
+ end
103
+
104
+ tests("#delete_security_group('not_a_group_name')").raises(Excon::Errors::BadRequest) do
105
+ AWS[:ec2].delete_security_group('not_a_group_name')
106
+ end
107
+
108
+ @security_group.destroy
109
+
110
+ end
111
+
112
+ end
@@ -6,41 +6,34 @@ Shindo.tests('AWS::EC2 | snapshot requests', ['aws']) do
6
6
 
7
7
  @snapshot_id = nil
8
8
 
9
- test("#create_snapshot(#{@volume.identity})") do
10
- @data = AWS[:ec2].create_snapshot(@volume.identity).body
11
- @snapshot_id = @data['snapshotId']
12
- has_format(@data, AWS::EC2::Formats::SNAPSHOT.merge('progress' => NilClass, 'requestId' => String))
9
+ tests("#create_snapshot(#{@volume.identity})").formats(AWS::EC2::Formats::SNAPSHOT.merge('progress' => NilClass, 'requestId' => String)) do
10
+ data = AWS[:ec2].create_snapshot(@volume.identity).body
11
+ @snapshot_id = data['snapshotId']
12
+ data
13
13
  end
14
14
 
15
- test("#describe_snapshots") do
15
+ tests("#describe_snapshots").formats(AWS::EC2::Formats::SNAPSHOTS) do
16
16
  AWS[:ec2].snapshots.get(@snapshot_id).wait_for { ready? }
17
- @data = AWS[:ec2].describe_snapshots.body
18
- has_format(@data, AWS::EC2::Formats::SNAPSHOTS)
17
+ AWS[:ec2].describe_snapshots.body
19
18
  end
20
19
 
21
- test("#describe_snapshots('#{@snapshot_id}')") do
22
- @data = AWS[:ec2].describe_snapshots(@snapshot_id).body
23
- has_format(@data, AWS::EC2::Formats::SNAPSHOTS)
20
+ tests("#describe_snapshots('#{@snapshot_id}')").formats(AWS::EC2::Formats::SNAPSHOTS) do
21
+ AWS[:ec2].describe_snapshots(@snapshot_id).body
24
22
  end
25
23
 
26
- test("#delete_snapshots(#{@snapshot_id})") do
27
- @data = AWS[:ec2].delete_snapshot(@snapshot_id).body
28
- has_format(@data, AWS::EC2::Formats::BASIC)
24
+ tests("#delete_snapshots(#{@snapshot_id})").formats(AWS::EC2::Formats::BASIC) do
25
+ AWS[:ec2].delete_snapshot(@snapshot_id).body
29
26
  end
30
27
 
31
28
  end
32
29
  tests ('failure') do
33
30
 
34
- test("#describe_snapshot('snap-00000000') raises BadRequest error") do
35
- has_error(Excon::Errors::BadRequest) do
36
- AWS[:ec2].describe_snapshots('snap-00000000')
37
- end
31
+ tests("#describe_snapshot('snap-00000000')").raises(Excon::Errors::BadRequest) do
32
+ AWS[:ec2].describe_snapshots('snap-00000000')
38
33
  end
39
34
 
40
- test("#delete_snapshot('snap-00000000') raises BadRequest error") do
41
- has_error(Excon::Errors::BadRequest) do
42
- AWS[:ec2].delete_snapshot('snap-00000000')
43
- end
35
+ tests("#delete_snapshot('snap-00000000')").raises(Excon::Errors::BadRequest) do
36
+ AWS[:ec2].delete_snapshot('snap-00000000')
44
37
  end
45
38
 
46
39
  end
@@ -7,37 +7,33 @@ Shindo.tests('AWS::EC2 | volume requests', ['aws']) do
7
7
 
8
8
  @volume_id = nil
9
9
 
10
- test('#create_volume') do
11
- @data = AWS[:ec2].create_volume(@server.availability_zone, 1).body
12
- @volume_id = @data['volumeId']
13
- has_format(@data, AWS::EC2::Formats::VOLUME)
10
+ tests('#create_volume').formats(AWS::EC2::Formats::VOLUME) do
11
+ data = AWS[:ec2].create_volume(@server.availability_zone, 1).body
12
+ @volume_id = data['volumeId']
13
+ data
14
14
  end
15
15
 
16
- test('#describe_volumes') do
17
- @data = AWS[:ec2].describe_volumes.body
18
- has_format(@data, AWS::EC2::Formats::VOLUMES)
16
+ tests('#describe_volumes').formats(AWS::EC2::Formats::VOLUMES) do
17
+ AWS[:ec2].describe_volumes.body
19
18
  end
20
19
 
21
- test("#describe_volumes(#{@volume_id})") do
22
- @data = AWS[:ec2].describe_volumes.body
23
- has_format(@data, AWS::EC2::Formats::VOLUMES)
20
+ tests("#describe_volumes(#{@volume_id})").formats(AWS::EC2::Formats::VOLUMES) do
21
+ AWS[:ec2].describe_volumes.body
24
22
  end
25
23
 
26
- test("#attach_volume(#{@server.identity}, #{@volume_id}, '/dev/sdh')") do
27
- @data = AWS[:ec2].attach_volume(@server.identity, @volume_id, '/dev/sdh').body
28
- has_format(@data, AWS::EC2::Formats::VOLUME_ATTACHMENT)
24
+ tests("#attach_volume(#{@server.identity}, #{@volume_id}, '/dev/sdh')").formats(AWS::EC2::Formats::VOLUME_ATTACHMENT) do
25
+ AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
26
+ AWS[:ec2].attach_volume(@server.identity, @volume_id, '/dev/sdh').body
29
27
  end
30
28
 
31
- test("#detach_volume('#{@volume_id}')") do
32
- AWS[:ec2].volumes.get(@volume_id).wait_for { state == 'attached' }
33
- @data = AWS[:ec2].detach_volume(@volume_id).body
34
- has_format(@data, AWS::EC2::Formats::VOLUME_ATTACHMENT)
29
+ tests("#detach_volume('#{@volume_id}')").formats(AWS::EC2::Formats::VOLUME_ATTACHMENT) do
30
+ AWS[:ec2].volumes.get(@volume_id).wait_for { state == 'in-use' }
31
+ AWS[:ec2].detach_volume(@volume_id).body
35
32
  end
36
33
 
37
- test("#delete_volume('#{@volume_id}')") do
34
+ tests("#delete_volume('#{@volume_id}')").formats(AWS::EC2::Formats::BASIC) do
38
35
  AWS[:ec2].volumes.get(@volume_id).wait_for { ready? }
39
- @data = AWS[:ec2].delete_volume(@volume_id).body
40
- has_format(@data, AWS::EC2::Formats::BASIC)
36
+ AWS[:ec2].delete_volume(@volume_id).body
41
37
  end
42
38
 
43
39
  end
@@ -45,34 +41,24 @@ Shindo.tests('AWS::EC2 | volume requests', ['aws']) do
45
41
 
46
42
  @volume = AWS[:ec2].volumes.create(:availability_zone => @server.availability_zone, :size => 1)
47
43
 
48
- test("#describe_volume('vol-00000000') raises BadRequest error") do
49
- has_error(Excon::Errors::BadRequest) do
50
- AWS[:ec2].describe_volumes('vol-00000000')
51
- end
44
+ tests("#describe_volume('vol-00000000')").raises(Excon::Errors::BadRequest) do
45
+ AWS[:ec2].describe_volumes('vol-00000000')
52
46
  end
53
47
 
54
- test("#attach_volume('i-00000000', '#{@volume.identity}', '/dev/sdh') raises BadRequest error") do
55
- has_error(Excon::Errors::BadRequest) do
56
- AWS[:ec2].attach_volume('i-00000000', @volume.identity, '/dev/sdh')
57
- end
48
+ tests("#attach_volume('i-00000000', '#{@volume.identity}', '/dev/sdh')").raises(Excon::Errors::BadRequest) do
49
+ AWS[:ec2].attach_volume('i-00000000', @volume.identity, '/dev/sdh')
58
50
  end
59
51
 
60
- test("#attach_volume('#{@server.identity}', 'vol-00000000', '/dev/sdh') raises BadRequest error") do
61
- has_error(Excon::Errors::BadRequest) do
62
- AWS[:ec2].attach_volume(@server.identity, 'vol-00000000', '/dev/sdh')
63
- end
52
+ tests("#attach_volume('#{@server.identity}', 'vol-00000000', '/dev/sdh')").raises(Excon::Errors::BadRequest) do
53
+ AWS[:ec2].attach_volume(@server.identity, 'vol-00000000', '/dev/sdh')
64
54
  end
65
55
 
66
- test("#detach_volume('vol-00000000') raises BadRequest error") do
67
- has_error(Excon::Errors::BadRequest) do
68
- AWS[:ec2].detach_volume('vol-00000000')
69
- end
56
+ tests("#detach_volume('vol-00000000')").raises(Excon::Errors::BadRequest) do
57
+ AWS[:ec2].detach_volume('vol-00000000')
70
58
  end
71
59
 
72
- test("#delete_volume('vol-00000000') raises BadRequest error") do
73
- has_error(Excon::Errors::BadRequest) do
74
- AWS[:ec2].delete_volume('vol-00000000')
75
- end
60
+ tests("#delete_volume('vol-00000000')").raises(Excon::Errors::BadRequest) do
61
+ AWS[:ec2].delete_volume('vol-00000000')
76
62
  end
77
63
 
78
64
  @volume.destroy
@@ -5,45 +5,60 @@ if ENV["FOG_MOCK"] == "true"
5
5
  Fog.mock!
6
6
  end
7
7
 
8
- def has_error(error, &block)
9
- begin
10
- yield
11
- @formatador.display_line("[red]did not raise #{error}[/]")
12
- false
13
- rescue error
14
- true
15
- end
16
- end
8
+ module Shindo
9
+ class Tests
17
10
 
18
- def has_format(original_data, original_format)
19
- valid = true
20
- data = original_data.dup
21
- format = original_format.dup
22
- for key, value in format
23
- valid &&= data.has_key?(key)
24
- datum = data.delete(key)
25
- format.delete(key)
26
- case value
27
- when Array
28
- valid &&= datum.is_a?(Array)
29
- for element in datum
30
- type = value.first
31
- if type.is_a?(Hash)
32
- valid &&= has_format({:element => element}, {:element => type})
11
+ def formats(format, &block)
12
+ test('has proper format') do
13
+ formats_kernel(instance_eval(&block), format)
14
+ end
15
+ end
16
+
17
+ def succeeds(&block)
18
+ test('succeeds') do
19
+ begin
20
+ instance_eval(&block)
21
+ true
22
+ rescue Exception, Interrupt
23
+ false
24
+ end
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ def formats_kernel(original_data, original_format, original = true)
31
+ valid = true
32
+ data = original_data.dup
33
+ format = original_format.dup
34
+ for key, value in format
35
+ valid &&= data.has_key?(key)
36
+ datum = data.delete(key)
37
+ format.delete(key)
38
+ case value
39
+ when Array
40
+ valid &&= datum.is_a?(Array)
41
+ for element in datum
42
+ type = value.first
43
+ if type.is_a?(Hash)
44
+ valid &&= formats_kernel({:element => element}, {:element => type}, false)
45
+ else
46
+ valid &&= element.is_a?(type)
47
+ end
48
+ end
49
+ when Hash
50
+ valid &&= datum.is_a?(Hash)
51
+ valid &&= formats_kernel(datum, value, false)
33
52
  else
34
- valid &&= element.is_a?(type)
53
+ valid &&= datum.is_a?(value)
35
54
  end
36
55
  end
37
- when Hash
38
- valid &&= datum.is_a?(Hash)
39
- valid &&= has_format(datum, value)
40
- else
41
- valid &&= datum.is_a?(value)
56
+ valid &&= data.empty? && format.empty?
57
+ if !valid && original
58
+ @message = "#{original_data.inspect} does not match #{original_format.inspect}"
59
+ end
60
+ valid
42
61
  end
62
+
43
63
  end
44
- valid &&= data.empty? && format.empty?
45
- unless valid
46
- @formatador.display_line("[red]#{original_data.inspect} does not match #{original_format.inspect}[/]")
47
- end
48
- valid
49
64
  end
@@ -35,8 +35,10 @@ module Rackspace
35
35
  }
36
36
 
37
37
  IMAGE = {
38
+ 'created' => String,
38
39
  'id' => Integer,
39
40
  'name' => String,
41
+ 'progress' => Integer,
40
42
  'serverId' => Integer,
41
43
  'status' => String,
42
44
  'updated' => String
@@ -1,22 +1,20 @@
1
1
  Shindo.tests('Rackspace::Servers#create_image', 'rackspace') do
2
2
  tests('success') do
3
3
 
4
- before do
5
- @server_id = Rackspace[:servers].create_server(1, 3, 'fogcreateimage').body['server']['id']
6
- Fog.wait_for { Rackspace[:servers].get_server_details(@server_id).body['server']['status'] == 'ACTIVE' }
7
- @data = Rackspace[:servers].create_image(@server_id).body['image']
8
- @image_id = @data['id']
9
- end
4
+ @server = Rackspace[:servers].servers.create(:flavor_id => 1, :image_id => 19, :name => 'foggetserverdetails')
5
+ @server.wait_for { ready? }
6
+ @image_id = nil
10
7
 
11
- after do
12
- Rackspace[:servers].delete_server(@server_id)
13
- Fog.wait_for { Rackspace[:servers].get_image_details(@image_id).body['image']['status'] == 'ACTIVE' }
14
- Rackspace[:servers].delete_image(@image_id)
8
+ tests("#create_image(#{@server.id})").formats(Rackspace::Servers::Formats::IMAGE.reject {|key,value| key == 'progress'}) do
9
+ data = Rackspace[:servers].create_image(@server.id).body['image']
10
+ @image_id = data['id']
11
+ data
15
12
  end
16
13
 
17
- test('has proper output format') do
18
- has_format(@data, Rackspace::Servers::Formats::IMAGE)
19
- end
14
+ @image = Rackspace[:servers].images.get(@image_id)
15
+ @image.wait_for { ready? }
16
+ @image.destroy
17
+ @server.destroy
20
18
 
21
19
  end
22
20
  end
@@ -1,20 +1,18 @@
1
1
  Shindo.tests('Rackspace::Servers#create_server', 'rackspace') do
2
2
  tests('success') do
3
3
 
4
- before do
5
- # 1 => 256MB, 3 => Gentoo
6
- @data = Rackspace[:servers].create_server(1, 3).body['server']
7
- @server_id = @data['id']
8
- end
4
+ @server_id = nil
9
5
 
10
- after do
11
- Fog.wait_for { Rackspace[:servers].get_server_details(@server_id).body['server']['status'] == 'ACTIVE' }
12
- Rackspace[:servers].delete_server(@server_id)
6
+ tests('#create_server(1, 19)').formats(Rackspace::Servers::Formats::SERVER.merge('adminPass' => String)) do
7
+ # 1 => 256MB, 19 => Gentoo
8
+ data = Rackspace[:servers].create_server(1, 19).body['server']
9
+ @server_id = data['id']
10
+ data
13
11
  end
14
12
 
15
- test('has proper output format') do
16
- has_format(@data, Rackspace::Servers::Formats::SERVER.merge('adminPass' => String))
17
- end
13
+ @server = Rackspace[:servers].servers.get(@server_id)
14
+ @server.wait_for { ready? }
15
+ @server.destroy
18
16
 
19
17
  end
20
18
  end