fog-core 2.2.4 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/core/model_spec.rb
CHANGED
@@ -3,6 +3,17 @@ require "securerandom"
|
|
3
3
|
|
4
4
|
class FogTestModel < Fog::Model
|
5
5
|
identity :id
|
6
|
+
attribute :value
|
7
|
+
|
8
|
+
def create
|
9
|
+
self.identity = SecureRandom.hex
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def update
|
14
|
+
self.value = 42
|
15
|
+
self
|
16
|
+
end
|
6
17
|
end
|
7
18
|
|
8
19
|
describe Fog::Model do
|
@@ -21,7 +32,7 @@ describe Fog::Model do
|
|
21
32
|
|
22
33
|
it "is equal if it has the same non-nil identity and the same class" do
|
23
34
|
id = SecureRandom.hex
|
24
|
-
assert_equal FogTestModel.new(:
|
35
|
+
assert_equal FogTestModel.new(id: id), FogTestModel.new(id: id)
|
25
36
|
end
|
26
37
|
|
27
38
|
it "is not equal if both have nil identity, but are different objects" do
|
@@ -29,8 +40,30 @@ describe Fog::Model do
|
|
29
40
|
end
|
30
41
|
|
31
42
|
it "is not equal if it has a different identity" do
|
32
|
-
refute_equal FogTestModel.new(:
|
33
|
-
FogTestModel.new(:
|
43
|
+
refute_equal FogTestModel.new(id: SecureRandom.hex),
|
44
|
+
FogTestModel.new(id: SecureRandom.hex)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "#save" do
|
49
|
+
describe "on a non persisted object" do
|
50
|
+
it "creates a new resource" do
|
51
|
+
a = FogTestModel.new
|
52
|
+
a.stub(:persisted?, false) do
|
53
|
+
a.save
|
54
|
+
refute_nil(a.identity)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "on a persisted object" do
|
60
|
+
it "updates resource" do
|
61
|
+
a = FogTestModel.new
|
62
|
+
a.stub(:persisted?, true) do
|
63
|
+
a.save
|
64
|
+
assert_equal(a.value, 42)
|
65
|
+
end
|
66
|
+
end
|
34
67
|
end
|
35
68
|
end
|
36
69
|
end
|
@@ -4,7 +4,7 @@ describe "Fog::StringifyKeys" do
|
|
4
4
|
describe ".stringify" do
|
5
5
|
describe "when key is a Symbol" do
|
6
6
|
it "replaces key with String" do
|
7
|
-
input = { :
|
7
|
+
input = { key: "value" }
|
8
8
|
output = Fog::StringifyKeys.stringify(input)
|
9
9
|
assert(output.key?("key"))
|
10
10
|
end
|
@@ -26,11 +26,11 @@ describe "Fog::StringifyKeys" do
|
|
26
26
|
|
27
27
|
describe "when keys are deeply nested" do
|
28
28
|
it "updates only top level key" do
|
29
|
-
input = { :
|
29
|
+
input = { key1: { key2: { key3: nil }}}
|
30
30
|
|
31
31
|
output = Fog::StringifyKeys.stringify(input)
|
32
32
|
|
33
|
-
expected = { "key1" => { :
|
33
|
+
expected = { "key1" => { key2: { key3: nil }}}
|
34
34
|
assert_equal(expected, output)
|
35
35
|
end
|
36
36
|
end
|
@@ -4,7 +4,7 @@ describe "Fog::WhitelistKeys" do
|
|
4
4
|
describe ".whitelist" do
|
5
5
|
describe "when other keys are present" do
|
6
6
|
it "returns Hash with only allowed keys" do
|
7
|
-
input = { :
|
7
|
+
input = { name: "name", type: "type", size: 80 }
|
8
8
|
valid_keys = %w(name size)
|
9
9
|
|
10
10
|
output = Fog::WhitelistKeys.whitelist(input, valid_keys)
|
@@ -16,7 +16,7 @@ describe "Fog::WhitelistKeys" do
|
|
16
16
|
|
17
17
|
describe "when key is a Symbol" do
|
18
18
|
it "returns a String" do
|
19
|
-
input = { :
|
19
|
+
input = { name: "name" }
|
20
20
|
valid_keys = %w(name)
|
21
21
|
|
22
22
|
output = Fog::WhitelistKeys.whitelist(input, valid_keys)
|
@@ -22,14 +22,14 @@ describe Fog::CurrentMachine do
|
|
22
22
|
|
23
23
|
(1..10).map do
|
24
24
|
Thread.new do
|
25
|
-
Excon.stub({ :
|
25
|
+
Excon.stub({ method: :get, path: "/" }, { body: "" })
|
26
26
|
Fog::CurrentMachine.ip_address
|
27
27
|
end
|
28
28
|
end.each(&:join)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should remove trailing endline characters" do
|
32
|
-
Excon.stub({ :
|
32
|
+
Excon.stub({ method: :get, path: "/" }, { body: "192.168.0.1\n" })
|
33
33
|
assert_equal "192.168.0.1", Fog::CurrentMachine.ip_address
|
34
34
|
end
|
35
35
|
end
|