fog 0.3.17 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/README.rdoc +16 -7
- data/fog.gemspec +102 -27
- data/lib/fog.rb +3 -2
- data/lib/fog/aws/cdn.rb +2 -1
- data/lib/fog/aws/compute.rb +3 -2
- data/lib/fog/aws/iam.rb +8 -0
- data/lib/fog/aws/models/compute/flavors.rb +2 -1
- data/lib/fog/aws/models/compute/server.rb +3 -0
- data/lib/fog/aws/models/compute/volume.rb +9 -8
- data/lib/fog/aws/models/storage/file.rb +24 -14
- data/lib/fog/aws/models/storage/files.rb +4 -14
- data/lib/fog/aws/parsers/cdn/distribution.rb +16 -1
- data/lib/fog/aws/parsers/cdn/get_distribution_list.rb +13 -0
- data/lib/fog/aws/parsers/compute/describe_volumes.rb +2 -0
- data/lib/fog/aws/parsers/iam/create_group.rb +2 -2
- data/lib/fog/aws/parsers/iam/create_user.rb +26 -0
- data/lib/fog/aws/parsers/iam/list_group_policies.rb +28 -0
- data/lib/fog/aws/parsers/iam/list_groups.rb +1 -1
- data/lib/fog/aws/parsers/storage/complete_multipart_upload.rb +24 -0
- data/lib/fog/aws/parsers/storage/initiate_multipart_upload.rb +24 -0
- data/lib/fog/aws/parsers/storage/list_multipart_uploads.rb +56 -0
- data/lib/fog/aws/parsers/storage/list_parts.rb +40 -0
- data/lib/fog/aws/requests/cdn/get_distribution.rb +11 -1
- data/lib/fog/aws/requests/cdn/get_distribution_list.rb +9 -1
- data/lib/fog/aws/requests/cdn/post_distribution.rb +16 -5
- data/lib/fog/aws/requests/cdn/put_distribution_config.rb +102 -0
- data/lib/fog/aws/requests/compute/describe_volumes.rb +1 -0
- data/lib/fog/aws/requests/compute/run_instances.rb +1 -1
- data/lib/fog/aws/requests/iam/add_user_to_group.rb +42 -0
- data/lib/fog/aws/requests/iam/create_group.rb +7 -3
- data/lib/fog/aws/requests/iam/create_user.rb +47 -0
- data/lib/fog/aws/requests/iam/delete_group.rb +5 -1
- data/lib/fog/aws/requests/iam/delete_group_policy.rb +42 -0
- data/lib/fog/aws/requests/iam/delete_user.rb +40 -0
- data/lib/fog/aws/requests/iam/list_group_policies.rb +47 -0
- data/lib/fog/aws/requests/iam/list_groups.rb +9 -4
- data/lib/fog/aws/requests/iam/put_group_policy.rb +44 -0
- data/lib/fog/aws/requests/iam/remove_user_from_group.rb +42 -0
- data/lib/fog/aws/requests/simpledb/put_attributes.rb +2 -2
- data/lib/fog/aws/requests/storage/abort_multipart_upload.rb +38 -0
- data/lib/fog/aws/requests/storage/complete_multipart_upload.rb +60 -0
- data/lib/fog/aws/requests/storage/get_service.rb +1 -1
- data/lib/fog/aws/requests/storage/initiate_multipart_upload.rb +55 -0
- data/lib/fog/aws/requests/storage/list_multipart_uploads.rb +68 -0
- data/lib/fog/aws/requests/storage/list_parts.rb +67 -0
- data/lib/fog/aws/requests/storage/put_object.rb +12 -5
- data/lib/fog/aws/requests/storage/upload_part.rb +51 -0
- data/lib/fog/aws/storage.rb +12 -6
- data/lib/fog/brightbox.rb +7 -0
- data/lib/fog/brightbox/bin.rb +23 -0
- data/lib/fog/brightbox/compute.rb +134 -0
- data/lib/fog/brightbox/models/compute/account.rb +51 -0
- data/lib/fog/brightbox/models/compute/cloud_ip.rb +43 -0
- data/lib/fog/brightbox/models/compute/cloud_ips.rb +34 -0
- data/lib/fog/brightbox/models/compute/flavor.rb +33 -0
- data/lib/fog/brightbox/models/compute/flavors.rb +28 -0
- data/lib/fog/brightbox/models/compute/image.rb +52 -0
- data/lib/fog/brightbox/models/compute/images.rb +28 -0
- data/lib/fog/brightbox/models/compute/server.rb +94 -0
- data/lib/fog/brightbox/models/compute/servers.rb +29 -0
- data/lib/fog/brightbox/models/compute/user.rb +39 -0
- data/lib/fog/brightbox/models/compute/users.rb +29 -0
- data/lib/fog/brightbox/models/compute/zone.rb +21 -0
- data/lib/fog/brightbox/models/compute/zones.rb +29 -0
- data/lib/fog/brightbox/requests/compute/create_api_client.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_cloud_ip.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_image.rb +27 -0
- data/lib/fog/brightbox/requests/compute/create_server.rb +27 -0
- data/lib/fog/brightbox/requests/compute/destroy_api_client.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_image.rb +28 -0
- data/lib/fog/brightbox/requests/compute/destroy_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_account.rb +27 -0
- data/lib/fog/brightbox/requests/compute/get_api_client.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_image.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_interface.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_server_type.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_user.rb +28 -0
- data/lib/fog/brightbox/requests/compute/get_zone.rb +28 -0
- data/lib/fog/brightbox/requests/compute/list_api_clients.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_cloud_ips.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_images.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_server_types.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_servers.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_users.rb +27 -0
- data/lib/fog/brightbox/requests/compute/list_zones.rb +27 -0
- data/lib/fog/brightbox/requests/compute/map_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/reset_ftp_password_account.rb +27 -0
- data/lib/fog/brightbox/requests/compute/resize_server.rb +27 -0
- data/lib/fog/brightbox/requests/compute/shutdown_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/snapshot_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/start_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/stop_server.rb +28 -0
- data/lib/fog/brightbox/requests/compute/unmap_cloud_ip.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_account.rb +28 -0
- data/lib/fog/brightbox/requests/compute/update_api_client.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_image.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_server.rb +29 -0
- data/lib/fog/brightbox/requests/compute/update_user.rb +29 -0
- data/lib/fog/core/attributes.rb +3 -3
- data/lib/fog/core/bin.rb +2 -0
- data/lib/fog/core/compute.rb +5 -2
- data/lib/fog/core/credentials.rb +2 -0
- data/lib/fog/core/service.rb +24 -12
- data/lib/fog/google/models/storage/file.rb +23 -14
- data/lib/fog/google/models/storage/files.rb +4 -14
- data/lib/fog/google/requests/storage/get_bucket.rb +0 -1
- data/lib/fog/google/requests/storage/put_object.rb +9 -2
- data/lib/fog/rackspace/models/storage/file.rb +3 -3
- data/lib/fog/rackspace/models/storage/files.rb +5 -13
- data/spec/aws/models/compute/server_spec.rb +0 -3
- data/spec/aws/requests/simpledb/get_attributes_spec.rb +11 -0
- data/spec/core/attributes_spec.rb +52 -0
- data/spec/vcloud/bin_spec.rb +1 -1
- data/spec/vcloud/vcloud_spec.rb +1 -1
- data/tests/aws/models/compute/flavors_tests.rb +5 -0
- data/tests/aws/models/compute/server_tests.rb +6 -0
- data/tests/aws/models/compute/servers_tests.rb +6 -0
- data/tests/aws/requests/storage/bucket_tests.rb +1 -1
- data/tests/aws/requests/storage/multipart_upload_tests.rb +135 -0
- data/tests/bluebox/models/compute/flavors_tests.rb +5 -0
- data/tests/bluebox/models/compute/server_tests.rb +5 -0
- data/tests/bluebox/models/compute/servers_tests.rb +6 -0
- data/tests/brightbox/helper.rb +0 -0
- data/tests/brightbox/models/compute/flavors_tests.rb +5 -0
- data/tests/brightbox/models/compute/server_tests.rb +6 -0
- data/tests/brightbox/models/compute/servers_tests.rb +6 -0
- data/tests/google/requests/storage/bucket_tests.rb +78 -0
- data/tests/google/requests/storage/object_tests.rb +81 -0
- data/tests/helper.rb +19 -4
- data/tests/helpers/collection_tests.rb +51 -0
- data/tests/helpers/compute/flavors_tests.rb +34 -0
- data/tests/helpers/compute/server_tests.rb +19 -0
- data/tests/helpers/compute/servers_tests.rb +11 -0
- data/tests/helpers/model_tests.rb +28 -0
- data/tests/helpers/storage/directories_tests.rb +4 -36
- data/tests/helpers/storage/directory_tests.rb +8 -22
- data/tests/helpers/storage/file_tests.rb +8 -25
- data/tests/helpers/storage/files_tests.rb +5 -39
- data/tests/local/models/storage/directories_tests.rb +1 -1
- data/tests/local/models/storage/directory_tests.rb +1 -1
- data/tests/local/models/storage/file_tests.rb +1 -1
- data/tests/local/models/storage/files_tests.rb +1 -1
- data/tests/rackspace/models/compute/flavors_tests.rb +5 -0
- data/tests/rackspace/models/compute/server_tests.rb +6 -0
- data/tests/rackspace/models/compute/servers_tests.rb +6 -0
- data/tests/rackspace/models/storage/directories_tests.rb +1 -1
- data/tests/rackspace/models/storage/directory_tests.rb +1 -1
- data/tests/rackspace/models/storage/file_tests.rb +1 -1
- data/tests/rackspace/models/storage/files_tests.rb +1 -1
- data/tests/slicehost/models/compute/flavors_tests.rb +5 -0
- data/tests/slicehost/models/compute/server_tests.rb +6 -0
- data/tests/slicehost/models/compute/servers_tests.rb +6 -0
- metadata +108 -31
- data/spec/aws/models/compute/flavors_spec.rb +0 -14
- data/spec/aws/models/compute/servers_spec.rb +0 -21
- data/spec/bluebox/models/compute/flavors_spec.rb +0 -17
- data/spec/bluebox/models/compute/server_spec.rb +0 -29
- data/spec/bluebox/models/compute/servers_spec.rb +0 -31
- data/spec/google/requests/storage/copy_object_spec.rb +0 -61
- data/spec/google/requests/storage/delete_bucket_spec.rb +0 -35
- data/spec/google/requests/storage/delete_object_spec.rb +0 -38
- data/spec/google/requests/storage/get_bucket_spec.rb +0 -110
- data/spec/google/requests/storage/get_object_spec.rb +0 -58
- data/spec/google/requests/storage/get_service_spec.rb +0 -32
- data/spec/google/requests/storage/head_object_spec.rb +0 -26
- data/spec/google/requests/storage/put_bucket_spec.rb +0 -21
- data/spec/google/requests/storage/put_object_spec.rb +0 -43
- data/spec/rackspace/models/compute/flavors_spec.rb +0 -18
- data/spec/rackspace/models/compute/server_spec.rb +0 -55
- data/spec/rackspace/models/compute/servers_spec.rb +0 -22
- data/spec/shared_examples/flavors_examples.rb +0 -16
- data/spec/shared_examples/server_examples.rb +0 -43
- data/spec/shared_examples/servers_examples.rb +0 -37
- data/spec/slicehost/models/compute/flavors_spec.rb +0 -18
- data/spec/slicehost/models/compute/server_spec.rb +0 -55
- data/spec/slicehost/models/compute/servers_spec.rb +0 -26
data/spec/vcloud/bin_spec.rb
CHANGED
data/spec/vcloud/vcloud_spec.rb
CHANGED
@@ -90,7 +90,7 @@ Shindo.tests('AWS::Storage | bucket requests', ['aws']) do
|
|
90
90
|
AWS[:storage].get_bucket_location('fognonbucket')
|
91
91
|
end
|
92
92
|
|
93
|
-
tests("#
|
93
|
+
tests("#get_request_payment('fognonbucket')").raises(Excon::Errors::NotFound) do
|
94
94
|
AWS[:storage].get_request_payment('fognonbucket')
|
95
95
|
end
|
96
96
|
|
@@ -0,0 +1,135 @@
|
|
1
|
+
Shindo.tests('AWS::Storage | object requests', ['aws']) do
|
2
|
+
|
3
|
+
@directory = AWS[:storage].directories.create(:key => 'fogmultipartuploadtests')
|
4
|
+
|
5
|
+
tests('success') do
|
6
|
+
|
7
|
+
@initiate_multipart_upload_format = {
|
8
|
+
'Bucket' => String,
|
9
|
+
'Key' => String,
|
10
|
+
'UploadId' => String
|
11
|
+
}
|
12
|
+
|
13
|
+
tests("#initiate_multipart_upload('#{@directory.identity}')", 'fog_multipart_upload').formats(@initiate_multipart_upload_format) do
|
14
|
+
pending if Fog.mocking?
|
15
|
+
data = AWS[:storage].initiate_multipart_upload(@directory.identity, 'fog_multipart_upload').body
|
16
|
+
@upload_id = data['UploadId']
|
17
|
+
data
|
18
|
+
end
|
19
|
+
|
20
|
+
@list_multipart_uploads_format = {
|
21
|
+
'Bucket' => String,
|
22
|
+
'IsTruncated' => Fog::Boolean,
|
23
|
+
'MaxUploads' => Integer,
|
24
|
+
'KeyMarker' => NilClass,
|
25
|
+
'NextKeyMarker' => String,
|
26
|
+
'NextUploadIdMarker' => String,
|
27
|
+
'Upload' => [{
|
28
|
+
'Initiated' => Time,
|
29
|
+
'Initiator' => {
|
30
|
+
'DisplayName' => String,
|
31
|
+
'ID' => String
|
32
|
+
},
|
33
|
+
'Key' => String,
|
34
|
+
'Owner' => {
|
35
|
+
'DisplayName' => String,
|
36
|
+
'ID' => String
|
37
|
+
},
|
38
|
+
'StorageClass' => String,
|
39
|
+
'UploadId' => String
|
40
|
+
}],
|
41
|
+
'UploadIdMarker' => NilClass,
|
42
|
+
}
|
43
|
+
|
44
|
+
tests("#list_multipart_uploads('#{@directory.identity})").formats(@list_multipart_uploads_format) do
|
45
|
+
pending if Fog.mocking?
|
46
|
+
AWS[:storage].list_multipart_uploads(@directory.identity).body
|
47
|
+
end
|
48
|
+
|
49
|
+
@parts = []
|
50
|
+
|
51
|
+
tests("#upload_part('#{@directory.identity}', 'fog_multipart_upload', '#{@upload_id}', 1, ('x' * 6 * 1024 * 1024))").succeeds do
|
52
|
+
pending if Fog.mocking?
|
53
|
+
data = AWS[:storage].upload_part(@directory.identity, 'fog_multipart_upload', @upload_id, 1, ('x' * 6 * 1024 * 1024))
|
54
|
+
@parts << data.headers['ETag']
|
55
|
+
end
|
56
|
+
|
57
|
+
@list_parts_format = {
|
58
|
+
'Bucket' => String,
|
59
|
+
'Initiator' => {
|
60
|
+
'DisplayName' => String,
|
61
|
+
'ID' => String
|
62
|
+
},
|
63
|
+
'IsTruncated' => Fog::Boolean,
|
64
|
+
'Key' => String,
|
65
|
+
'MaxParts' => Integer,
|
66
|
+
'NextPartNumberMarker' => String,
|
67
|
+
'Part' => [{
|
68
|
+
'ETag' => String,
|
69
|
+
'LastModified' => Time,
|
70
|
+
'PartNumber' => Integer,
|
71
|
+
'Size' => Integer
|
72
|
+
}],
|
73
|
+
'PartNumberMarker' => String,
|
74
|
+
'StorageClass' => String,
|
75
|
+
'UploadId' => String
|
76
|
+
}
|
77
|
+
|
78
|
+
tests("#list_parts('#{@directory.identity}', 'fog_multipart_upload', '#{@upload_id}')").formats(@list_parts_format) do
|
79
|
+
pending if Fog.mocking?
|
80
|
+
AWS[:storage].list_parts(@directory.identity, 'fog_multipart_upload', @upload_id).body
|
81
|
+
end
|
82
|
+
|
83
|
+
if !Fog.mocking?
|
84
|
+
@parts << AWS[:storage].upload_part(@directory.identity, 'fog_multipart_upload', @upload_id, 2, ('x' * 4 * 1024 * 1024)).headers['ETag']
|
85
|
+
end
|
86
|
+
|
87
|
+
@complete_multipart_upload_format = {
|
88
|
+
'Bucket' => String,
|
89
|
+
'ETag' => String,
|
90
|
+
'Key' => String,
|
91
|
+
'Location' => String
|
92
|
+
}
|
93
|
+
|
94
|
+
tests("#complete_multipart_upload('#{@directory.identity}', 'fog_multipart_upload', '#{@upload_id}', #{@parts.inspect})").formats(@complete_multipart_upload_format) do
|
95
|
+
pending if Fog.mocking?
|
96
|
+
AWS[:storage].complete_multipart_upload(@directory.identity, 'fog_multipart_upload', @upload_id, @parts).body
|
97
|
+
end
|
98
|
+
|
99
|
+
tests("#get_object('#{@directory.identity}', 'fog_multipart_upload').body").succeeds do
|
100
|
+
pending if Fog.mocking?
|
101
|
+
data = AWS[:storage].get_object(@directory.identity, 'fog_multipart_upload').body
|
102
|
+
unless data == ('x' * 10 * 1024 * 1024)
|
103
|
+
raise 'content mismatch'
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
if !Fog.mocking?
|
108
|
+
@directory.files.new(:key => 'fog_multipart_upload').destroy
|
109
|
+
end
|
110
|
+
|
111
|
+
if !Fog.mocking?
|
112
|
+
@upload_id = AWS[:storage].initiate_multipart_upload(@directory.identity, 'fog_multipart_abort').body['UploadId']
|
113
|
+
end
|
114
|
+
|
115
|
+
tests("#abort_multipart_upload('#{@directory.identity}', 'fog_multipart_abort', '#{@upload_id}')").succeeds do
|
116
|
+
pending if Fog.mocking?
|
117
|
+
AWS[:storage].abort_multipart_upload(@directory.identity, 'fog_multipart_abort', @upload_id)
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
tests('failure') do
|
123
|
+
|
124
|
+
tests("initiate_multipart_upload")
|
125
|
+
tests("list_multipart_uploads")
|
126
|
+
tests("upload_part")
|
127
|
+
tests("list_parts")
|
128
|
+
tests("complete_multipart_upload")
|
129
|
+
tests("abort_multipart_upload")
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
@directory.destroy
|
134
|
+
|
135
|
+
end
|
File without changes
|
@@ -0,0 +1,78 @@
|
|
1
|
+
Shindo.tests('Google::Storage | bucket requests', ['google']) do
|
2
|
+
|
3
|
+
tests('success') do
|
4
|
+
|
5
|
+
@bucket_format = {
|
6
|
+
'IsTruncated' => Fog::Boolean,
|
7
|
+
'Marker' => NilClass,
|
8
|
+
'Name' => String,
|
9
|
+
'Prefix' => NilClass,
|
10
|
+
'Contents' => [{
|
11
|
+
'ETag' => String,
|
12
|
+
'Key' => String,
|
13
|
+
'LastModified' => Time,
|
14
|
+
'Owner' => {
|
15
|
+
'DisplayName' => String,
|
16
|
+
'ID' => String
|
17
|
+
},
|
18
|
+
'Size' => Integer,
|
19
|
+
'StorageClass' => String
|
20
|
+
}]
|
21
|
+
}
|
22
|
+
|
23
|
+
@service_format = {
|
24
|
+
'Buckets' => [{
|
25
|
+
'CreationDate' => Time,
|
26
|
+
'Name' => String,
|
27
|
+
}],
|
28
|
+
'Owner' => {
|
29
|
+
'DisplayName' => String,
|
30
|
+
'ID' => String
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
tests("#put_bucket('fogbuckettests')").succeeds do
|
35
|
+
Google[:storage].put_bucket('fogbuckettests')
|
36
|
+
end
|
37
|
+
|
38
|
+
tests("#get_service").formats(@service_format) do
|
39
|
+
Google[:storage].get_service.body
|
40
|
+
end
|
41
|
+
|
42
|
+
file = Google[:storage].directories.get('fogbuckettests').files.create(:body => 'y', :key => 'x')
|
43
|
+
|
44
|
+
tests("#get_bucket('fogbuckettests)").formats(@bucket_format) do
|
45
|
+
Google[:storage].get_bucket('fogbuckettests').body
|
46
|
+
end
|
47
|
+
|
48
|
+
file.destroy
|
49
|
+
|
50
|
+
tests("#delete_bucket('fogbuckettests')").succeeds do
|
51
|
+
Google[:storage].delete_bucket('fogbuckettests')
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
tests('failure') do
|
57
|
+
|
58
|
+
tests("#delete_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
|
59
|
+
Google[:storage].delete_bucket('fognonbucket')
|
60
|
+
end
|
61
|
+
|
62
|
+
@bucket = Google[:storage].directories.create(:key => 'fognonempty')
|
63
|
+
@file = @bucket.files.create(:key => 'foo', :body => 'bar')
|
64
|
+
|
65
|
+
tests("#delete_bucket('fognonempty')").raises(Excon::Errors::Conflict) do
|
66
|
+
Google[:storage].delete_bucket('fognonempty')
|
67
|
+
end
|
68
|
+
|
69
|
+
@file.destroy
|
70
|
+
@bucket.destroy
|
71
|
+
|
72
|
+
tests("#get_bucket('fognonbucket')").raises(Excon::Errors::NotFound) do
|
73
|
+
Google[:storage].get_bucket('fognonbucket')
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
Shindo.tests('Google::Storage | object requests', ['google']) do
|
2
|
+
|
3
|
+
@directory = Google[:storage].directories.create(:key => 'fogobjecttests')
|
4
|
+
|
5
|
+
tests('success') do
|
6
|
+
|
7
|
+
tests("#put_object('#{@directory.identity}', 'fog_object', lorem_file)").succeeds do
|
8
|
+
Google[:storage].put_object(@directory.identity, 'fog_object', lorem_file)
|
9
|
+
end
|
10
|
+
|
11
|
+
tests("#copy_object('#{@directory.identity}', 'fog_object', '#{@directory.identity}', 'fog_other_object')").succeeds do
|
12
|
+
Google[:storage].copy_object(@directory.identity, 'fog_object', @directory.identity, 'fog_other_object')
|
13
|
+
end
|
14
|
+
|
15
|
+
@directory.files.get('fog_other_object').destroy
|
16
|
+
|
17
|
+
tests("#get_object('#{@directory.identity}', 'fog_object')").returns(lorem_file.read) do
|
18
|
+
Google[:storage].get_object(@directory.identity, 'fog_object').body
|
19
|
+
end
|
20
|
+
|
21
|
+
tests("#get_object('#{@directory.identity}', 'fog_object', &block)").returns(lorem_file.read) do
|
22
|
+
data = ''
|
23
|
+
Google[:storage].get_object(@directory.identity, 'fog_object') do |chunk|
|
24
|
+
data << chunk
|
25
|
+
end
|
26
|
+
data
|
27
|
+
end
|
28
|
+
|
29
|
+
tests("#head_object('#{@directory.identity}', 'fog_object')").succeeds do
|
30
|
+
Google[:storage].head_object(@directory.identity, 'fog_object')
|
31
|
+
end
|
32
|
+
|
33
|
+
tests("#delete_object('#{@directory.identity}', 'fog_object')").succeeds do
|
34
|
+
Google[:storage].delete_object(@directory.identity, 'fog_object')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
tests('failure') do
|
40
|
+
|
41
|
+
tests("#put_object('fognonbucket', 'fog_non_object', lorem_file)").raises(Excon::Errors::NotFound) do
|
42
|
+
Google[:storage].put_object('fognonbucket', 'fog_non_object', lorem_file)
|
43
|
+
end
|
44
|
+
|
45
|
+
tests("#copy_object('fognonbucket', 'fog_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
46
|
+
Google[:storage].copy_object('fognonbucket', 'fog_object', @directory.identity, 'fog_other_object')
|
47
|
+
end
|
48
|
+
|
49
|
+
tests("#copy_object('#{@directory.identity}', 'fog_non_object', '#{@directory.identity}', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
50
|
+
Google[:storage].copy_object(@directory.identity, 'fog_non_object', @directory.identity, 'fog_other_object')
|
51
|
+
end
|
52
|
+
|
53
|
+
tests("#copy_object('#{@directory.identity}', 'fog_object', 'fognonbucket', 'fog_other_object')").raises(Excon::Errors::NotFound) do
|
54
|
+
Google[:storage].copy_object(@directory.identity, 'fog_object', 'fognonbucket', 'fog_other_object')
|
55
|
+
end
|
56
|
+
|
57
|
+
tests("#get_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
58
|
+
Google[:storage].get_object('fognonbucket', 'fog_non_object')
|
59
|
+
end
|
60
|
+
|
61
|
+
tests("#get_object('#{@directory.identity}', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
62
|
+
Google[:storage].get_object(@directory.identity, 'fog_non_object')
|
63
|
+
end
|
64
|
+
|
65
|
+
tests("#head_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
66
|
+
Google[:storage].head_object('fognonbucket', 'fog_non_object')
|
67
|
+
end
|
68
|
+
|
69
|
+
tests("#head_object('#{@directory.identity}', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
70
|
+
Google[:storage].head_object(@directory.identity, 'fog_non_object')
|
71
|
+
end
|
72
|
+
|
73
|
+
tests("#delete_object('fognonbucket', 'fog_non_object')").raises(Excon::Errors::NotFound) do
|
74
|
+
Google[:storage].delete_object('fognonbucket', 'fog_non_object')
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
@directory.destroy
|
80
|
+
|
81
|
+
end
|
data/tests/helper.rb
CHANGED
@@ -8,6 +8,13 @@ $LOAD_PATH.unshift __DIR__ unless
|
|
8
8
|
$LOAD_PATH.include?(__DIR__) ||
|
9
9
|
$LOAD_PATH.include?(File.expand_path(__DIR__))
|
10
10
|
|
11
|
+
require 'tests/helpers/collection_tests'
|
12
|
+
require 'tests/helpers/model_tests'
|
13
|
+
|
14
|
+
require 'tests/helpers/compute/flavors_tests'
|
15
|
+
require 'tests/helpers/compute/server_tests'
|
16
|
+
require 'tests/helpers/compute/servers_tests'
|
17
|
+
|
11
18
|
require 'tests/helpers/storage/directory_tests'
|
12
19
|
require 'tests/helpers/storage/directories_tests'
|
13
20
|
require 'tests/helpers/storage/file_tests'
|
@@ -32,15 +39,23 @@ end
|
|
32
39
|
module Shindo
|
33
40
|
class Tests
|
34
41
|
|
35
|
-
def
|
42
|
+
def responds_to(method_names)
|
43
|
+
for method_name in [*method_names]
|
44
|
+
tests("#respond_to?(:#{method_name})").succeeds do
|
45
|
+
@instance.respond_to?(method_name)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def formats(format)
|
36
51
|
test('has proper format') do
|
37
|
-
formats_kernel(instance_eval(&
|
52
|
+
formats_kernel(instance_eval(&Proc.new), format)
|
38
53
|
end
|
39
54
|
end
|
40
55
|
|
41
|
-
def succeeds
|
56
|
+
def succeeds
|
42
57
|
test('succeeds') do
|
43
|
-
instance_eval(&
|
58
|
+
instance_eval(&Proc.new)
|
44
59
|
true
|
45
60
|
end
|
46
61
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
def collection_tests(collection, params = {}, mocks_implemented = true)
|
2
|
+
|
3
|
+
tests('success') do
|
4
|
+
|
5
|
+
tests("#new(#{params.inspect})").succeeds do
|
6
|
+
pending if Fog.mocking? && !mocks_implemented
|
7
|
+
collection.new(params)
|
8
|
+
end
|
9
|
+
|
10
|
+
tests("#create(#{params.inspect})").succeeds do
|
11
|
+
pending if Fog.mocking? && !mocks_implemented
|
12
|
+
@instance = collection.create(params)
|
13
|
+
end
|
14
|
+
|
15
|
+
tests("#all").succeeds do
|
16
|
+
pending if Fog.mocking? && !mocks_implemented
|
17
|
+
collection.all
|
18
|
+
end
|
19
|
+
|
20
|
+
if !Fog.mocking? || mocks_implemented
|
21
|
+
@identity = @instance.identity
|
22
|
+
end
|
23
|
+
|
24
|
+
tests("#get(#{@identity})").succeeds do
|
25
|
+
pending if Fog.mocking? && !mocks_implemented
|
26
|
+
collection.get(@identity)
|
27
|
+
end
|
28
|
+
|
29
|
+
if block_given?
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
|
33
|
+
if !Fog.mocking? || mocks_implemented
|
34
|
+
@instance.destroy
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
tests('failure') do
|
39
|
+
|
40
|
+
if !Fog.mocking? || mocks_implemented
|
41
|
+
@identity = @identity.to_s.gsub(/\w/, '0')
|
42
|
+
end
|
43
|
+
|
44
|
+
tests("#get('#{@identity}')").returns(nil) do
|
45
|
+
pending if Fog.mocking? && !mocks_implemented
|
46
|
+
collection.get(@identity)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|