fog-serverlove 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.hound.yml +20 -0
- data/.rubocop.yml +20 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +18 -0
- data/CONTRIBUTORS.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE.md +20 -0
- data/README.md +38 -0
- data/Rakefile +18 -0
- data/fog-serverlove.gemspec +35 -0
- data/gemfiles/Gemfile.1.9.2- +8 -0
- data/gemfiles/Gemfile.1.9.3+ +7 -0
- data/lib/fog/compute/serverlove.rb +95 -0
- data/lib/fog/compute/serverlove/models/image.rb +52 -0
- data/lib/fog/compute/serverlove/models/images.rb +19 -0
- data/lib/fog/compute/serverlove/models/server.rb +67 -0
- data/lib/fog/compute/serverlove/models/servers.rb +19 -0
- data/lib/fog/compute/serverlove/password_generator.rb +11 -0
- data/lib/fog/compute/serverlove/requests/create_image.rb +28 -0
- data/lib/fog/compute/serverlove/requests/create_server.rb +30 -0
- data/lib/fog/compute/serverlove/requests/destroy_image.rb +11 -0
- data/lib/fog/compute/serverlove/requests/destroy_server.rb +11 -0
- data/lib/fog/compute/serverlove/requests/get_image.rb +11 -0
- data/lib/fog/compute/serverlove/requests/get_images.rb +11 -0
- data/lib/fog/compute/serverlove/requests/get_server.rb +11 -0
- data/lib/fog/compute/serverlove/requests/get_servers.rb +11 -0
- data/lib/fog/compute/serverlove/requests/load_standard_image.rb +11 -0
- data/lib/fog/compute/serverlove/requests/reset_server.rb +11 -0
- data/lib/fog/compute/serverlove/requests/shutdown_server.rb +11 -0
- data/lib/fog/compute/serverlove/requests/start_server.rb +11 -0
- data/lib/fog/compute/serverlove/requests/stop_server.rb +11 -0
- data/lib/fog/compute/serverlove/requests/update_image.rb +13 -0
- data/lib/fog/compute/serverlove/requests/update_server.rb +13 -0
- data/lib/fog/serverlove.rb +15 -0
- data/lib/fog/serverlove/compute.rb +0 -0
- data/lib/fog/serverlove/version.rb +5 -0
- data/spec/minitest_helper.rb +31 -0
- data/tests/compute/password_generator_tests.rb +15 -0
- data/tests/compute/requests/image_tests.rb +59 -0
- data/tests/compute/requests/server_tests.rb +92 -0
- data/tests/helper.rb +34 -0
- data/tests/helpers/collection_helper.rb +97 -0
- data/tests/helpers/flavors_helper.rb +32 -0
- data/tests/helpers/formats_helper.rb +98 -0
- data/tests/helpers/formats_helper_tests.rb +110 -0
- data/tests/helpers/model_helper.rb +29 -0
- data/tests/helpers/responds_to_helper.rb +11 -0
- data/tests/helpers/schema_validator_tests.rb +107 -0
- data/tests/helpers/server_helper.rb +25 -0
- data/tests/helpers/servers_helper.rb +10 -0
- data/tests/helpers/succeeds_helper.rb +9 -0
- metadata +227 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
def model_tests(collection, params = {}, mocks_implemented = true)
|
2
|
+
tests('success') do
|
3
|
+
@instance = collection.new(params)
|
4
|
+
|
5
|
+
tests("#save").succeeds do
|
6
|
+
pending if Fog.mocking? && !mocks_implemented
|
7
|
+
@instance.save
|
8
|
+
end
|
9
|
+
|
10
|
+
if block_given?
|
11
|
+
yield(@instance)
|
12
|
+
end
|
13
|
+
|
14
|
+
tests("#destroy").succeeds do
|
15
|
+
pending if Fog.mocking? && !mocks_implemented
|
16
|
+
@instance.destroy
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Generates a unique identifier with a random differentiator.
|
22
|
+
# Useful when rapidly re-running tests, so we don't have to wait
|
23
|
+
# serveral minutes for deleted objects to disappear from the API
|
24
|
+
# E.g. 'fog-test-1234'
|
25
|
+
def uniq_id(base_name = 'fog-test')
|
26
|
+
# random_differentiator
|
27
|
+
suffix = rand(65536).to_s(16).rjust(4, '0')
|
28
|
+
[base_name, suffix] * '-'
|
29
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
Shindo.tests('Fog::Schema::DataValidator', 'meta') do
|
2
|
+
|
3
|
+
validator = Fog::Schema::DataValidator.new
|
4
|
+
|
5
|
+
tests('#validate') do
|
6
|
+
|
7
|
+
tests('returns true') do
|
8
|
+
|
9
|
+
returns(true, 'when value matches schema expectation') do
|
10
|
+
validator.validate({"key" => "Value"}, {"key" => String})
|
11
|
+
end
|
12
|
+
|
13
|
+
returns(true, 'when values within an array all match schema expectation') do
|
14
|
+
validator.validate({"key" => [1, 2]}, {"key" => [Integer]})
|
15
|
+
end
|
16
|
+
|
17
|
+
returns(true, 'when nested values match schema expectation') do
|
18
|
+
validator.validate({"key" => {:nested_key => "Value"}}, {"key" => {:nested_key => String}})
|
19
|
+
end
|
20
|
+
|
21
|
+
returns(true, 'when collection of values all match schema expectation') do
|
22
|
+
validator.validate([{"key" => "Value"}, {"key" => "Value"}], [{"key" => String}])
|
23
|
+
end
|
24
|
+
|
25
|
+
returns(true, 'when collection is empty although schema covers optional members') do
|
26
|
+
validator.validate([], [{"key" => String}])
|
27
|
+
end
|
28
|
+
|
29
|
+
returns(true, 'when additional keys are passed and not strict') do
|
30
|
+
validator.validate({"key" => "Value", :extra => "Bonus"}, {"key" => String}, {:allow_extra_keys => true})
|
31
|
+
end
|
32
|
+
|
33
|
+
returns(true, 'when value is nil and schema expects NilClass') do
|
34
|
+
validator.validate({"key" => nil}, {"key" => NilClass})
|
35
|
+
end
|
36
|
+
|
37
|
+
returns(true, 'when value and schema match as hashes') do
|
38
|
+
validator.validate({}, {})
|
39
|
+
end
|
40
|
+
|
41
|
+
returns(true, 'when value and schema match as arrays') do
|
42
|
+
validator.validate([], [])
|
43
|
+
end
|
44
|
+
|
45
|
+
returns(true, 'when value is a Time') do
|
46
|
+
validator.validate({"time" => Time.now}, {"time" => Time})
|
47
|
+
end
|
48
|
+
|
49
|
+
returns(true, 'when key is missing but value should be NilClass (#1477)') do
|
50
|
+
validator.validate({}, {"key" => NilClass}, {:allow_optional_rules => true})
|
51
|
+
end
|
52
|
+
|
53
|
+
returns(true, 'when key is missing but value is nullable (#1477)') do
|
54
|
+
validator.validate({}, {"key" => Fog::Nullable::String}, {:allow_optional_rules => true})
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
tests('returns false') do
|
60
|
+
|
61
|
+
returns(false, 'when value does not match schema expectation') do
|
62
|
+
validator.validate({"key" => nil}, {"key" => String})
|
63
|
+
end
|
64
|
+
|
65
|
+
returns(false, 'when key formats do not match') do
|
66
|
+
validator.validate({"key" => "Value"}, {:key => String})
|
67
|
+
end
|
68
|
+
|
69
|
+
returns(false, 'when additional keys are passed and strict') do
|
70
|
+
validator.validate({"key" => "Missing"}, {})
|
71
|
+
end
|
72
|
+
|
73
|
+
returns(false, 'when some keys do not appear') do
|
74
|
+
validator.validate({}, {"key" => String})
|
75
|
+
end
|
76
|
+
|
77
|
+
returns(false, 'when collection contains a member that does not match schema') do
|
78
|
+
validator.validate([{"key" => "Value"}, {"key" => 5}], [{"key" => String}])
|
79
|
+
end
|
80
|
+
|
81
|
+
returns(false, 'when collection has multiple schema patterns') do
|
82
|
+
validator.validate([{"key" => "Value"}], [{"key" => Integer}, {"key" => String}])
|
83
|
+
end
|
84
|
+
|
85
|
+
returns(false, 'when hash and array are compared') do
|
86
|
+
validator.validate({}, [])
|
87
|
+
end
|
88
|
+
|
89
|
+
returns(false, 'when array and hash are compared') do
|
90
|
+
validator.validate([], {})
|
91
|
+
end
|
92
|
+
|
93
|
+
returns(false, 'when a hash is expected but another data type is found') do
|
94
|
+
validator.validate({"key" => {:nested_key => []}}, {"key" => {:nested_key => {}}})
|
95
|
+
end
|
96
|
+
|
97
|
+
returns(false, 'when key is missing but value should be NilClass (#1477)') do
|
98
|
+
validator.validate({}, {"key" => NilClass}, {:allow_optional_rules => false})
|
99
|
+
end
|
100
|
+
|
101
|
+
returns(false, 'when key is missing but value is nullable (#1477)') do
|
102
|
+
validator.validate({}, {"key" => Fog::Nullable::String}, {:allow_optional_rules => false})
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
def server_tests(connection, params = {}, mocks_implemented = true)
|
2
|
+
model_tests(connection.servers, params, mocks_implemented) do
|
3
|
+
|
4
|
+
tests('#reload').returns(true) do
|
5
|
+
pending if Fog.mocking? && !mocks_implemented
|
6
|
+
@instance.wait_for { ready? }
|
7
|
+
identity = @instance.identity
|
8
|
+
!identity.nil? && identity == @instance.reload.identity
|
9
|
+
end
|
10
|
+
|
11
|
+
responds_to([:ready?, :state])
|
12
|
+
yield if block_given?
|
13
|
+
|
14
|
+
tests('#reboot').succeeds do
|
15
|
+
pending if Fog.mocking? && !mocks_implemented
|
16
|
+
@instance.wait_for { ready? }
|
17
|
+
@instance.reboot
|
18
|
+
end
|
19
|
+
|
20
|
+
if !Fog.mocking? || mocks_implemented
|
21
|
+
@instance.wait_for { ready? }
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,227 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fog-serverlove
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paulo Henrique Lopes Ribeiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: fog-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fog-json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: shindo
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: turn
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rubocop
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: |-
|
140
|
+
This library can be used as a module for `fog` or as standalone provider
|
141
|
+
to use the ServerLove in applications.
|
142
|
+
email:
|
143
|
+
- plribeiro3000@gmail.com
|
144
|
+
executables: []
|
145
|
+
extensions: []
|
146
|
+
extra_rdoc_files: []
|
147
|
+
files:
|
148
|
+
- ".gitignore"
|
149
|
+
- ".hound.yml"
|
150
|
+
- ".rubocop.yml"
|
151
|
+
- ".ruby-gemset"
|
152
|
+
- ".ruby-version"
|
153
|
+
- ".travis.yml"
|
154
|
+
- CONTRIBUTING.md
|
155
|
+
- CONTRIBUTORS.md
|
156
|
+
- Gemfile
|
157
|
+
- LICENSE.md
|
158
|
+
- README.md
|
159
|
+
- Rakefile
|
160
|
+
- fog-serverlove.gemspec
|
161
|
+
- gemfiles/Gemfile.1.9.2-
|
162
|
+
- gemfiles/Gemfile.1.9.3+
|
163
|
+
- lib/fog/compute/serverlove.rb
|
164
|
+
- lib/fog/compute/serverlove/models/image.rb
|
165
|
+
- lib/fog/compute/serverlove/models/images.rb
|
166
|
+
- lib/fog/compute/serverlove/models/server.rb
|
167
|
+
- lib/fog/compute/serverlove/models/servers.rb
|
168
|
+
- lib/fog/compute/serverlove/password_generator.rb
|
169
|
+
- lib/fog/compute/serverlove/requests/create_image.rb
|
170
|
+
- lib/fog/compute/serverlove/requests/create_server.rb
|
171
|
+
- lib/fog/compute/serverlove/requests/destroy_image.rb
|
172
|
+
- lib/fog/compute/serverlove/requests/destroy_server.rb
|
173
|
+
- lib/fog/compute/serverlove/requests/get_image.rb
|
174
|
+
- lib/fog/compute/serverlove/requests/get_images.rb
|
175
|
+
- lib/fog/compute/serverlove/requests/get_server.rb
|
176
|
+
- lib/fog/compute/serverlove/requests/get_servers.rb
|
177
|
+
- lib/fog/compute/serverlove/requests/load_standard_image.rb
|
178
|
+
- lib/fog/compute/serverlove/requests/reset_server.rb
|
179
|
+
- lib/fog/compute/serverlove/requests/shutdown_server.rb
|
180
|
+
- lib/fog/compute/serverlove/requests/start_server.rb
|
181
|
+
- lib/fog/compute/serverlove/requests/stop_server.rb
|
182
|
+
- lib/fog/compute/serverlove/requests/update_image.rb
|
183
|
+
- lib/fog/compute/serverlove/requests/update_server.rb
|
184
|
+
- lib/fog/serverlove.rb
|
185
|
+
- lib/fog/serverlove/compute.rb
|
186
|
+
- lib/fog/serverlove/version.rb
|
187
|
+
- spec/minitest_helper.rb
|
188
|
+
- tests/compute/password_generator_tests.rb
|
189
|
+
- tests/compute/requests/image_tests.rb
|
190
|
+
- tests/compute/requests/server_tests.rb
|
191
|
+
- tests/helper.rb
|
192
|
+
- tests/helpers/collection_helper.rb
|
193
|
+
- tests/helpers/flavors_helper.rb
|
194
|
+
- tests/helpers/formats_helper.rb
|
195
|
+
- tests/helpers/formats_helper_tests.rb
|
196
|
+
- tests/helpers/model_helper.rb
|
197
|
+
- tests/helpers/responds_to_helper.rb
|
198
|
+
- tests/helpers/schema_validator_tests.rb
|
199
|
+
- tests/helpers/server_helper.rb
|
200
|
+
- tests/helpers/servers_helper.rb
|
201
|
+
- tests/helpers/succeeds_helper.rb
|
202
|
+
homepage: ''
|
203
|
+
licenses:
|
204
|
+
- MIT
|
205
|
+
metadata: {}
|
206
|
+
post_install_message:
|
207
|
+
rdoc_options: []
|
208
|
+
require_paths:
|
209
|
+
- lib
|
210
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: '0'
|
215
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
|
+
requirements:
|
217
|
+
- - ">="
|
218
|
+
- !ruby/object:Gem::Version
|
219
|
+
version: '0'
|
220
|
+
requirements: []
|
221
|
+
rubyforge_project:
|
222
|
+
rubygems_version: 2.4.3
|
223
|
+
signing_key:
|
224
|
+
specification_version: 4
|
225
|
+
summary: Module for the 'fog' gem to support ServerLove.
|
226
|
+
test_files:
|
227
|
+
- spec/minitest_helper.rb
|