fog-core 2.2.4 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +2 -0
- data/.github/workflows/ruby.yml +1 -17
- data/.github/workflows/stale.yml +1 -15
- data/.rubocop.yml +16 -12
- data/.rubocop_todo.yml +724 -0
- data/Gemfile +1 -1
- data/Rakefile +2 -14
- data/changelog.md +33 -3
- data/fog-core.gemspec +11 -8
- data/lib/fog/compute/models/server.rb +7 -3
- data/lib/fog/compute.rb +2 -2
- data/lib/fog/core/association.rb +1 -0
- data/lib/fog/core/attributes/default.rb +7 -0
- data/lib/fog/core/attributes.rb +28 -3
- data/lib/fog/core/cache.rb +58 -55
- data/lib/fog/core/collection.rb +9 -3
- data/lib/fog/core/connection.rb +1 -1
- data/lib/fog/core/current_machine.rb +1 -1
- data/lib/fog/core/errors.rb +1 -1
- data/lib/fog/core/logger.rb +2 -2
- data/lib/fog/core/mock.rb +6 -1
- data/lib/fog/core/model.rb +34 -5
- data/lib/fog/core/provider.rb +18 -17
- data/lib/fog/core/scp.rb +15 -11
- data/lib/fog/core/service.rb +4 -4
- data/lib/fog/core/services_mixin.rb +9 -9
- data/lib/fog/core/ssh.rb +3 -2
- data/lib/fog/core/stringify_keys.rb +0 -2
- data/lib/fog/core/time.rb +2 -2
- data/lib/fog/core/uuid.rb +2 -8
- data/lib/fog/core/version.rb +1 -1
- data/lib/fog/core/wait_for.rb +2 -1
- data/lib/fog/core/wait_for_defaults.rb +2 -0
- data/lib/fog/core.rb +57 -58
- data/lib/fog/formatador.rb +7 -6
- data/lib/fog/schema/data_validator.rb +1 -0
- data/lib/fog/storage.rb +15 -15
- data/lib/fog/test_helpers/collection_helper.rb +2 -0
- data/lib/fog/test_helpers/formats_helper.rb +2 -2
- data/lib/fog/test_helpers/helper.rb +3 -3
- data/lib/fog/test_helpers/minitest/assertions.rb +1 -1
- data/lib/fog/test_helpers/minitest/expectations.rb +1 -1
- data/lib/fog/test_helpers/mock_helper.rb +84 -84
- data/lib/fog/test_helpers/types_helper.rb +1 -0
- data/lib/tasks/test_task.rb +2 -2
- data/spec/compute/models/server_spec.rb +7 -7
- data/spec/compute_spec.rb +23 -23
- data/spec/connection_spec.rb +11 -9
- data/spec/core/cache_spec.rb +52 -16
- data/spec/core/collection_spec.rb +24 -0
- data/spec/core/model_spec.rb +36 -3
- data/spec/core/stringify_keys_spec.rb +3 -3
- data/spec/core/whitelist_keys_spec.rb +2 -2
- data/spec/current_machine_spec.rb +2 -2
- data/spec/fog_attribute_spec.rb +183 -163
- data/spec/formatador_spec.rb +7 -7
- data/spec/identity_spec.rb +23 -23
- data/spec/mocking_spec.rb +3 -3
- data/spec/service_spec.rb +19 -19
- data/spec/spec_helper.rb +3 -8
- data/spec/storage_spec.rb +23 -23
- data/spec/test_helpers/formats_helper_spec.rb +8 -8
- data/spec/test_helpers/schema_validator_spec.rb +8 -8
- data/spec/utils_spec.rb +6 -6
- data/spec/wait_for_spec.rb +2 -2
- metadata +51 -54
data/spec/formatador_spec.rb
CHANGED
@@ -26,15 +26,15 @@ describe Fog::Formatador do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
@collection = @collection_class.new(:
|
30
|
-
@collection << @member_class.new(:
|
29
|
+
@collection = @collection_class.new(attr_one: "String", attr_two: 5)
|
30
|
+
@collection << @member_class.new(name: "Member name")
|
31
31
|
@expected = <<-EOS.gsub(/^ {6}/, "").chomp!
|
32
32
|
<InspectionGadget
|
33
|
-
attr_one
|
33
|
+
attr_one="String",
|
34
34
|
attr_two=5
|
35
35
|
[
|
36
36
|
<MemberGadget
|
37
|
-
name
|
37
|
+
name="Member name"
|
38
38
|
>
|
39
39
|
]
|
40
40
|
>
|
@@ -78,18 +78,18 @@ describe Fog::Formatador do
|
|
78
78
|
self
|
79
79
|
end
|
80
80
|
end
|
81
|
-
@collection = @collection_class.new(:
|
81
|
+
@collection = @collection_class.new(name: "Name")
|
82
82
|
@collection << "this"
|
83
83
|
end
|
84
84
|
|
85
85
|
it "returns formatted representation" do
|
86
86
|
@expected = <<-EOS.gsub(/^ {6}/, "").chomp!
|
87
87
|
<
|
88
|
-
name
|
88
|
+
name="Name"
|
89
89
|
>
|
90
90
|
EOS
|
91
91
|
|
92
|
-
opts = { :
|
92
|
+
opts = { include_nested: false }
|
93
93
|
Fog::Formatador.format(@collection, opts).must_equal @expected
|
94
94
|
end
|
95
95
|
end
|
data/spec/identity_spec.rb
CHANGED
@@ -8,13 +8,6 @@ end
|
|
8
8
|
|
9
9
|
describe "Fog::Identity" do
|
10
10
|
describe "#new" do
|
11
|
-
module Fog
|
12
|
-
module TheRightWay
|
13
|
-
extend Provider
|
14
|
-
service(:identity, "Identity")
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
11
|
module Fog
|
19
12
|
module TheRightWay
|
20
13
|
class Identity
|
@@ -23,18 +16,18 @@ describe "Fog::Identity" do
|
|
23
16
|
end
|
24
17
|
end
|
25
18
|
|
26
|
-
it "instantiates an instance of Fog::Identity::<Provider> from the :provider keyword arg" do
|
27
|
-
identity = Fog::Identity.new(:provider => :therightway)
|
28
|
-
assert_instance_of(Fog::TheRightWay::Identity, identity)
|
29
|
-
end
|
30
|
-
|
31
19
|
module Fog
|
32
|
-
module
|
20
|
+
module TheRightWay
|
33
21
|
extend Provider
|
34
22
|
service(:identity, "Identity")
|
35
23
|
end
|
36
24
|
end
|
37
25
|
|
26
|
+
it "instantiates an instance of Fog::Identity::<Provider> from the :provider keyword arg" do
|
27
|
+
identity = Fog::Identity.new(provider: :therightway)
|
28
|
+
assert_instance_of(Fog::TheRightWay::Identity, identity)
|
29
|
+
end
|
30
|
+
|
38
31
|
module Fog
|
39
32
|
module Identity
|
40
33
|
class TheWrongWay
|
@@ -43,18 +36,18 @@ describe "Fog::Identity" do
|
|
43
36
|
end
|
44
37
|
end
|
45
38
|
|
46
|
-
it "instantiates an instance of Fog::<Provider>::Identity from the :provider keyword arg" do
|
47
|
-
identity = Fog::Identity.new(:provider => :thewrongway)
|
48
|
-
assert_instance_of(Fog::Identity::TheWrongWay, identity)
|
49
|
-
end
|
50
|
-
|
51
39
|
module Fog
|
52
|
-
module
|
40
|
+
module TheWrongWay
|
53
41
|
extend Provider
|
54
42
|
service(:identity, "Identity")
|
55
43
|
end
|
56
44
|
end
|
57
45
|
|
46
|
+
it "instantiates an instance of Fog::<Provider>::Identity from the :provider keyword arg" do
|
47
|
+
identity = Fog::Identity.new(provider: :thewrongway)
|
48
|
+
assert_instance_of(Fog::Identity::TheWrongWay, identity)
|
49
|
+
end
|
50
|
+
|
58
51
|
module Fog
|
59
52
|
module BothWays
|
60
53
|
class Identity
|
@@ -74,21 +67,28 @@ describe "Fog::Identity" do
|
|
74
67
|
end
|
75
68
|
end
|
76
69
|
|
70
|
+
module Fog
|
71
|
+
module BothWays
|
72
|
+
extend Provider
|
73
|
+
service(:identity, "Identity")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
77
|
describe "when both Fog::Identity::<Provider> and Fog::<Provider>::Identity exist" do
|
78
78
|
it "prefers Fog::Identity::<Provider>" do
|
79
|
-
identity = Fog::Identity.new(:
|
79
|
+
identity = Fog::Identity.new(provider: :bothways)
|
80
80
|
assert_instance_of(Fog::BothWays::Identity, identity)
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
84
|
it "passes the supplied keyword args less :provider to Fog::Identity::<Provider>#new" do
|
85
|
-
identity = Fog::Identity.new(:
|
86
|
-
assert_equal({ :
|
85
|
+
identity = Fog::Identity.new(provider: :bothways, extra: :stuff)
|
86
|
+
assert_equal({ extra: :stuff }, identity.args)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "raises ArgumentError when given a :provider where a Fog::Identity::Provider that does not exist" do
|
90
90
|
assert_raises(ArgumentError) do
|
91
|
-
Fog::Identity.new(:
|
91
|
+
Fog::Identity.new(provider: :wat)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
data/spec/mocking_spec.rb
CHANGED
@@ -60,16 +60,16 @@ describe "Fog mocking" do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "supports explicit request for v4" do
|
63
|
-
assert IPAddr.new(Fog::Mock.random_ip(:
|
63
|
+
assert IPAddr.new(Fog::Mock.random_ip(version: :v4)).ipv4?
|
64
64
|
end
|
65
65
|
|
66
66
|
it "supports explicit request for v6" do
|
67
|
-
assert IPAddr.new(Fog::Mock.random_ip(:
|
67
|
+
assert IPAddr.new(Fog::Mock.random_ip(version: :v6)).ipv6?
|
68
68
|
end
|
69
69
|
|
70
70
|
it "raises when supplied an illegal IP version" do
|
71
71
|
assert_raises(ArgumentError) do
|
72
|
-
IPAddr.new(Fog::Mock.random_ip(:
|
72
|
+
IPAddr.new(Fog::Mock.random_ip(version: :v5)).ipv4?
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
data/spec/service_spec.rb
CHANGED
@@ -32,10 +32,10 @@ describe Fog::Service do
|
|
32
32
|
"User-Agent" => "Generic Fog Client"
|
33
33
|
}
|
34
34
|
params = {
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
35
|
+
generic_user: "bob",
|
36
|
+
generic_api_key: "1234",
|
37
|
+
connection_options: {
|
38
|
+
headers: user_agent_hash
|
39
39
|
}
|
40
40
|
}
|
41
41
|
service = TestService.new(params)
|
@@ -54,27 +54,27 @@ describe Fog::Service do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it "removes keys with `nil` values" do
|
57
|
-
service = TestService.new :
|
57
|
+
service = TestService.new generic_api_key: "abc", generic_user: nil
|
58
58
|
refute_includes service.options.keys, :generic_user
|
59
59
|
end
|
60
60
|
|
61
61
|
it "converts number String values with to_i" do
|
62
|
-
service = TestService.new :
|
62
|
+
service = TestService.new generic_api_key: "3421"
|
63
63
|
assert_equal 3421, service.options[:generic_api_key]
|
64
64
|
end
|
65
65
|
|
66
66
|
it "converts 'true' String values to TrueClass" do
|
67
|
-
service = TestService.new :
|
67
|
+
service = TestService.new generic_api_key: "true"
|
68
68
|
assert_equal true, service.options[:generic_api_key]
|
69
69
|
end
|
70
70
|
|
71
71
|
it "converts 'false' String values to FalseClass" do
|
72
|
-
service = TestService.new :
|
72
|
+
service = TestService.new generic_api_key: "false"
|
73
73
|
assert_equal false, service.options[:generic_api_key]
|
74
74
|
end
|
75
75
|
|
76
76
|
it "warns for unrecognised options" do
|
77
|
-
bad_options = { :
|
77
|
+
bad_options = { generic_api_key: "abc", bad_option: "bad value" }
|
78
78
|
logger = Minitest::Mock.new
|
79
79
|
logger.expect :warning, nil, ["Unrecognized arguments: bad_option"]
|
80
80
|
Fog.stub_const :Logger, logger do
|
@@ -87,14 +87,14 @@ describe Fog::Service do
|
|
87
87
|
describe "when creating and mocking is disabled" do
|
88
88
|
it "returns the real service" do
|
89
89
|
Fog.stub :mocking?, false do
|
90
|
-
service = TestService.new(:
|
90
|
+
service = TestService.new(generic_api_key: "abc")
|
91
91
|
service.must_be_instance_of TestService::Real
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
95
|
it "TestService::Real has TestService::Collections mixed into the mocked service" do
|
96
96
|
Fog.stub :mocking?, false do
|
97
|
-
service = TestService.new(:
|
97
|
+
service = TestService.new(generic_api_key: "abc")
|
98
98
|
assert_includes(service.class.ancestors, TestService::Collections)
|
99
99
|
assert_includes(service.class.ancestors, Fog::Service::Collections)
|
100
100
|
refute_includes(service.class.ancestors, ChildOfTestService::Collections)
|
@@ -114,14 +114,14 @@ describe Fog::Service do
|
|
114
114
|
describe "when creating and mocking is enabled" do
|
115
115
|
it "returns mocked service" do
|
116
116
|
Fog.stub :mocking?, true do
|
117
|
-
service = TestService.new(:
|
117
|
+
service = TestService.new(generic_api_key: "abc")
|
118
118
|
service.must_be_instance_of TestService::Mock
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
122
|
it "TestService::Mock has TestService::Collections mixed into the mocked service" do
|
123
123
|
Fog.stub :mocking?, true do
|
124
|
-
service = TestService.new(:
|
124
|
+
service = TestService.new(generic_api_key: "abc")
|
125
125
|
assert_includes(service.class.ancestors, Fog::Service::Collections)
|
126
126
|
assert_includes(service.class.ancestors, TestService::Collections)
|
127
127
|
refute_includes(service.class.ancestors, ChildOfTestService::Collections)
|
@@ -141,8 +141,8 @@ describe Fog::Service do
|
|
141
141
|
describe "when no credentials are provided" do
|
142
142
|
it "uses the global values" do
|
143
143
|
@global_credentials = {
|
144
|
-
:
|
145
|
-
:
|
144
|
+
generic_user: "fog",
|
145
|
+
generic_api_key: "fog"
|
146
146
|
}
|
147
147
|
|
148
148
|
Fog.stub :credentials, @global_credentials do
|
@@ -155,11 +155,11 @@ describe Fog::Service do
|
|
155
155
|
describe "when credentials are provided as settings" do
|
156
156
|
it "merges the global values into settings" do
|
157
157
|
@settings = {
|
158
|
-
:
|
158
|
+
generic_user: "fog"
|
159
159
|
}
|
160
160
|
@global_credentials = {
|
161
|
-
:
|
162
|
-
:
|
161
|
+
generic_user: "bob",
|
162
|
+
generic_api_key: "fog"
|
163
163
|
}
|
164
164
|
|
165
165
|
Fog.stub :credentials, @global_credentials do
|
@@ -172,7 +172,7 @@ describe Fog::Service do
|
|
172
172
|
|
173
173
|
describe "when config object can configure the service itself" do
|
174
174
|
it "ignores the global and its values" do
|
175
|
-
@config =
|
175
|
+
@config = Minitest::Mock.new
|
176
176
|
def @config.config_service?; true; end
|
177
177
|
def @config.nil?; false; end
|
178
178
|
def @config.==(other); object_id == other.object_id; end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
SimpleCov.start do
|
6
|
-
add_filter "/spec/"
|
7
|
-
end
|
8
|
-
end
|
1
|
+
# Set home outside of real user
|
2
|
+
require "tmpdir"
|
3
|
+
ENV["HOME"] = Dir.mktmpdir("foghome")
|
9
4
|
|
10
5
|
require "minitest/autorun"
|
11
6
|
require "minitest/spec"
|
data/spec/storage_spec.rb
CHANGED
@@ -10,49 +10,42 @@ describe "Fog::Storage" do
|
|
10
10
|
describe "#new" do
|
11
11
|
module Fog
|
12
12
|
module TheRightWay
|
13
|
-
|
14
|
-
|
13
|
+
class Storage
|
14
|
+
def initialize(_args); end
|
15
|
+
end
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
18
19
|
module Fog
|
19
20
|
module TheRightWay
|
20
|
-
|
21
|
-
|
22
|
-
end
|
21
|
+
extend Provider
|
22
|
+
service(:storage, "Storage")
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
it "instantiates an instance of Fog::<Provider>::Storage from the :provider keyword arg" do
|
27
|
-
compute = Fog::Storage.new(:
|
27
|
+
compute = Fog::Storage.new(provider: :therightway)
|
28
28
|
assert_instance_of(Fog::TheRightWay::Storage, compute)
|
29
29
|
end
|
30
30
|
|
31
31
|
module Fog
|
32
|
-
module TheWrongWay
|
33
|
-
extend Provider
|
34
|
-
service(:storage, "Storage")
|
35
|
-
end
|
36
|
-
|
37
32
|
module Storage
|
38
33
|
class TheWrongWay
|
39
34
|
def initialize(_args); end
|
40
35
|
end
|
41
36
|
end
|
42
|
-
end
|
43
|
-
|
44
|
-
it "instantiates an instance of Fog::Storage::<Provider> from the :provider keyword arg" do
|
45
|
-
compute = Fog::Storage.new(:provider => :thewrongway)
|
46
|
-
assert_instance_of(Fog::Storage::TheWrongWay, compute)
|
47
|
-
end
|
48
37
|
|
49
|
-
|
50
|
-
module BothWays
|
38
|
+
module TheWrongWay
|
51
39
|
extend Provider
|
52
40
|
service(:storage, "Storage")
|
53
41
|
end
|
54
42
|
end
|
55
43
|
|
44
|
+
it "instantiates an instance of Fog::Storage::<Provider> from the :provider keyword arg" do
|
45
|
+
compute = Fog::Storage.new(provider: :thewrongway)
|
46
|
+
assert_instance_of(Fog::Storage::TheWrongWay, compute)
|
47
|
+
end
|
48
|
+
|
56
49
|
module Fog
|
57
50
|
module BothWays
|
58
51
|
class Storage
|
@@ -73,21 +66,28 @@ describe "Fog::Storage" do
|
|
73
66
|
end
|
74
67
|
end
|
75
68
|
|
69
|
+
module Fog
|
70
|
+
module BothWays
|
71
|
+
extend Provider
|
72
|
+
service(:storage, "Storage")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
76
|
describe "when both Fog::Storage::<Provider> and Fog::<Provider>::Storage exist" do
|
77
77
|
it "prefers Fog::Storage::<Provider>" do
|
78
|
-
compute = Fog::Storage.new(:
|
78
|
+
compute = Fog::Storage.new(provider: :bothways)
|
79
79
|
assert_instance_of(Fog::BothWays::Storage, compute)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
83
|
it "passes the supplied keyword args less :provider to Fog::Storage::<Provider>#new" do
|
84
|
-
compute = Fog::Storage.new(:
|
85
|
-
assert_equal({ :
|
84
|
+
compute = Fog::Storage.new(provider: :bothways, extra: :stuff)
|
85
|
+
assert_equal({ extra: :stuff }, compute.args)
|
86
86
|
end
|
87
87
|
|
88
88
|
it "raises ArgumentError when given a :provider where a Fog::Storage::Provider that does not exist" do
|
89
89
|
assert_raises(ArgumentError) do
|
90
|
-
Fog::Storage.new(:
|
90
|
+
Fog::Storage.new(provider: :wat)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -14,8 +14,8 @@ describe "formats_helper" do
|
|
14
14
|
let(:shindo) { Shindo::Tests.new }
|
15
15
|
|
16
16
|
it "comparing welcome data against schema" do
|
17
|
-
data = { :
|
18
|
-
assert shindo.data_matches_schema(:
|
17
|
+
data = { welcome: "Hello" }
|
18
|
+
assert shindo.data_matches_schema(welcome: String) { data }
|
19
19
|
end
|
20
20
|
|
21
21
|
describe "#data_matches_schema" do
|
@@ -28,7 +28,7 @@ describe "formats_helper" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it "when nested values match schema expectation" do
|
31
|
-
assert shindo.data_matches_schema("key" => { :
|
31
|
+
assert shindo.data_matches_schema("key" => { nested_key: String }) { { "key" => { nested_key: "Value" } } }
|
32
32
|
end
|
33
33
|
|
34
34
|
it "when collection of values all match schema expectation" do
|
@@ -36,11 +36,11 @@ describe "formats_helper" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it "when collection is empty although schema covers optional members" do
|
39
|
-
assert shindo.data_matches_schema([{ "key" => String }], :
|
39
|
+
assert shindo.data_matches_schema([{ "key" => String }], allow_optional_rules: true) { [] }
|
40
40
|
end
|
41
41
|
|
42
42
|
it "when additional keys are passed and not strict" do
|
43
|
-
assert shindo.data_matches_schema({ "key" => String }, { :
|
43
|
+
assert shindo.data_matches_schema({ "key" => String }, { allow_extra_keys: true }) { { "key" => "Value", :extra => "Bonus" } }
|
44
44
|
end
|
45
45
|
|
46
46
|
it "when value is nil and schema expects NilClass" do
|
@@ -60,11 +60,11 @@ describe "formats_helper" do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "when key is missing but value should be NilClass (#1477)" do
|
63
|
-
assert shindo.data_matches_schema({ "key" => NilClass }, { :
|
63
|
+
assert shindo.data_matches_schema({ "key" => NilClass }, { allow_optional_rules: true }) { {} }
|
64
64
|
end
|
65
65
|
|
66
66
|
it "when key is missing but value is nullable (#1477)" do
|
67
|
-
assert shindo.data_matches_schema({ "key" => Fog::Nullable::String }, { :
|
67
|
+
assert shindo.data_matches_schema({ "key" => Fog::Nullable::String }, { allow_optional_rules: true }) { {} }
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -79,7 +79,7 @@ describe "formats_helper" do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "when nested values match schema expectation" do
|
82
|
-
assert shindo.formats("key" => { :
|
82
|
+
assert shindo.formats("key" => { nested_key: String }) { { "key" => { nested_key: "Value" } } }
|
83
83
|
end
|
84
84
|
|
85
85
|
it "when collection of values all match schema expectation" do
|
@@ -15,7 +15,7 @@ describe "SchemaValidator" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it "returns true when nested values match schema expectation" do
|
18
|
-
assert validator.validate({ "key" => { :
|
18
|
+
assert validator.validate({ "key" => { nested_key: "Value" } }, { "key" => { nested_key: String } })
|
19
19
|
end
|
20
20
|
|
21
21
|
it "returns true when collection of values all match schema expectation" do
|
@@ -27,7 +27,7 @@ describe "SchemaValidator" do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns true when additional keys are passed and not strict" do
|
30
|
-
assert validator.validate({ "key" => "Value", :extra => "Bonus" }, { "key" => String }, { :
|
30
|
+
assert validator.validate({ "key" => "Value", :extra => "Bonus" }, { "key" => String }, { allow_extra_keys: true })
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns true when value is nil and schema expects NilClass" do
|
@@ -47,11 +47,11 @@ describe "SchemaValidator" do
|
|
47
47
|
end
|
48
48
|
|
49
49
|
it "returns true when key is missing but value should be NilClass (#1477)" do
|
50
|
-
assert validator.validate({}, { "key" => NilClass }, { :
|
50
|
+
assert validator.validate({}, { "key" => NilClass }, { allow_optional_rules: true })
|
51
51
|
end
|
52
52
|
|
53
53
|
it "returns true when key is missing but value is nullable (#1477)" do
|
54
|
-
assert validator.validate({}, { "key" => Fog::Nullable::String }, { :
|
54
|
+
assert validator.validate({}, { "key" => Fog::Nullable::String }, { allow_optional_rules: true })
|
55
55
|
end
|
56
56
|
|
57
57
|
it "returns false when value does not match schema expectation" do
|
@@ -59,7 +59,7 @@ describe "SchemaValidator" do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
it "returns false when key formats do not match" do
|
62
|
-
refute validator.validate({ "key" => "Value" }, { :
|
62
|
+
refute validator.validate({ "key" => "Value" }, { key: String })
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns false when additional keys are passed and strict" do
|
@@ -87,15 +87,15 @@ describe "SchemaValidator" do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "returns false when a hash is expected but another data type is found" do
|
90
|
-
refute validator.validate({ "key" => { :
|
90
|
+
refute validator.validate({ "key" => { nested_key: [] } }, { "key" => { nested_key: {} } })
|
91
91
|
end
|
92
92
|
|
93
93
|
it "returns false when key is missing but value should be NilClass (#1477)" do
|
94
|
-
refute validator.validate({}, { "key" => NilClass }, { :
|
94
|
+
refute validator.validate({}, { "key" => NilClass }, { allow_optional_rules: false })
|
95
95
|
end
|
96
96
|
|
97
97
|
it "returns false when key is missing but value is nullable (#1477)" do
|
98
|
-
refute validator.validate({}, { "key" => Fog::Nullable::String }, { :
|
98
|
+
refute validator.validate({}, { "key" => Fog::Nullable::String }, { allow_optional_rules: false })
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
data/spec/utils_spec.rb
CHANGED
@@ -4,25 +4,25 @@ describe Fog::Core::Utils do
|
|
4
4
|
describe "prepare_service_settings" do
|
5
5
|
it "changes String keys to be Symbols" do
|
6
6
|
settings = { "a" => 3 }
|
7
|
-
expected = { :
|
7
|
+
expected = { a: 3 }
|
8
8
|
assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
|
9
9
|
end
|
10
10
|
|
11
11
|
it "leaves Symbol keys unchanged" do
|
12
|
-
settings = { :
|
13
|
-
expected = { :
|
12
|
+
settings = { something: 2 }
|
13
|
+
expected = { something: 2 }
|
14
14
|
assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
|
15
15
|
end
|
16
16
|
|
17
17
|
it "changes nested String keys to Symbols" do
|
18
18
|
settings = { "connection_options" => { "val" => 5 } }
|
19
|
-
expected = { :
|
19
|
+
expected = { connection_options: { val: 5 } }
|
20
20
|
assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "does not change the :header key or contents" do
|
24
|
-
settings = { :
|
25
|
-
expected = { :
|
24
|
+
settings = { headers: { "User-Agent" => "my user agent" } }
|
25
|
+
expected = { headers: { "User-Agent" => "my user agent" } }
|
26
26
|
assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
|
27
27
|
end
|
28
28
|
end
|
data/spec/wait_for_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe "Fog#wait_for" do
|
4
4
|
it "returns a Hash indicating the wait duration if successful" do
|
5
|
-
assert_equal({ :
|
5
|
+
assert_equal({ duration: 0 }, Fog.wait_for(1) { true })
|
6
6
|
end
|
7
7
|
|
8
8
|
it "raises if the wait timeout is exceeded" do
|
@@ -14,7 +14,7 @@ describe "Fog#wait_for" do
|
|
14
14
|
it "does not raise if successful when the wait timeout is exceeded" do
|
15
15
|
timeout = 2
|
16
16
|
i = 0
|
17
|
-
ret = Fog.wait_for(timeout) { i
|
17
|
+
ret = Fog.wait_for(timeout) { i += 1; i > 2 }
|
18
18
|
assert_operator(ret[:duration], :>, timeout)
|
19
19
|
end
|
20
20
|
|