schemata-dea 0.0.1.beta16 → 0.0.1.beta17
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.
- data/lib/schemata/common/componentbase.rb +9 -6
- data/lib/schemata/common/msgtypebase.rb +8 -5
- data/lib/schemata/dea/start_request/start_request_v1.rb +5 -13
- data/lib/schemata/dea/version.rb +1 -1
- data/spec/common/componentbase_spec.rb +18 -0
- data/spec/common/msgtypebase_spec.rb +16 -0
- data/spec/support/component_helpers.rb +3 -7
- data/spec/support/message_helpers.rb +2 -6
- metadata +5 -1
@@ -27,15 +27,18 @@ module Schemata
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def require_message_classes
|
30
|
-
path =
|
31
|
-
|
32
|
-
|
30
|
+
path = [
|
31
|
+
File.expand_path("../../", __FILE__),
|
32
|
+
"/",
|
33
|
+
Schemata::Helpers.decamelize(component_name),
|
34
|
+
"/*.rb"
|
35
|
+
].join
|
33
36
|
Dir.glob(path, &method(:require))
|
34
37
|
end
|
35
38
|
|
36
|
-
def self.extended(
|
37
|
-
|
38
|
-
|
39
|
+
def self.extended(mod)
|
40
|
+
mod.require_message_classes
|
41
|
+
mod.register_mock_methods
|
39
42
|
end
|
40
43
|
|
41
44
|
end
|
@@ -80,11 +80,14 @@ module Schemata
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def require_message_versions
|
83
|
-
path =
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
83
|
+
path = [
|
84
|
+
File.expand_path("../../", __FILE__),
|
85
|
+
"/",
|
86
|
+
Schemata::Helpers.decamelize(component_name),
|
87
|
+
"/",
|
88
|
+
Schemata::Helpers.decamelize(message_type_name),
|
89
|
+
"/*.rb"
|
90
|
+
].join
|
88
91
|
|
89
92
|
Dir.glob(path, &method(:require))
|
90
93
|
end
|
@@ -21,12 +21,7 @@ module Schemata
|
|
21
21
|
"version_output" => String,
|
22
22
|
"version_flag" => String,
|
23
23
|
"additional_checks" => String,
|
24
|
-
"environment"
|
25
|
-
"LD_LIBRARY_PATH" => String,
|
26
|
-
"BUNDLE_GEMFILE" => enum(String, NilClass),
|
27
|
-
"PATH" => String,
|
28
|
-
"GEM_PATH" => String
|
29
|
-
},
|
24
|
+
"environment" => Hash,
|
30
25
|
"status" => {
|
31
26
|
"name" => String
|
32
27
|
},
|
@@ -42,7 +37,7 @@ module Schemata
|
|
42
37
|
"version" => String,
|
43
38
|
"services" => [{
|
44
39
|
"label" => String,
|
45
|
-
"tags" => [String],
|
40
|
+
optional("tags") => [String],
|
46
41
|
"name" => String,
|
47
42
|
"credentials" => {
|
48
43
|
"hostname" => String,
|
@@ -57,10 +52,9 @@ module Schemata
|
|
57
52
|
optional("user") => String,
|
58
53
|
optional("pass") => String,
|
59
54
|
},
|
60
|
-
"options" => any,
|
61
55
|
"plan" => String,
|
62
|
-
"plan_option"
|
63
|
-
"type"
|
56
|
+
optional("plan_option") => enum(String, NilClass),
|
57
|
+
optional("type") => String,
|
64
58
|
"version" => String,
|
65
59
|
"vendor" => String
|
66
60
|
}],
|
@@ -70,9 +64,8 @@ module Schemata
|
|
70
64
|
"fds" => Integer
|
71
65
|
},
|
72
66
|
"env" => [String],
|
73
|
-
"users" => [String],
|
74
67
|
"cc_partition" => String,
|
75
|
-
"debug"
|
68
|
+
optional("debug") => any,
|
76
69
|
"console" => any,
|
77
70
|
"index" => Integer,
|
78
71
|
optional("flapping") => bool,
|
@@ -129,7 +122,6 @@ module Schemata
|
|
129
122
|
"fds" => 256
|
130
123
|
},
|
131
124
|
"env" => [],
|
132
|
-
"users" => ["user@rbcon.com"],
|
133
125
|
"cc_partition" => "default",
|
134
126
|
"debug" => nil,
|
135
127
|
"console" => nil,
|
data/lib/schemata/dea/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'schemata/dea'
|
3
|
+
require 'schemata/common/componentbase'
|
4
|
+
|
5
|
+
describe Schemata::ComponentBase do
|
6
|
+
let(:component) { Schemata::Dea }
|
7
|
+
|
8
|
+
describe '#require_message_classes' do
|
9
|
+
subject { component.require_message_classes }
|
10
|
+
|
11
|
+
it 'require the full path as consumers will need absolute not relative paths' do
|
12
|
+
Dir.should_receive(:glob).with(File.expand_path("../../../lib/schemata/dea/*.rb", __FILE__))
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'schemata/dea'
|
3
|
+
require 'schemata/common/msgtypebase'
|
4
|
+
|
5
|
+
describe Schemata::MessageTypeBase do
|
6
|
+
let(:msgtype) { Schemata::Dea::AdvertiseMessage }
|
7
|
+
|
8
|
+
describe '#require_message_versions' do
|
9
|
+
subject { msgtype.require_message_versions }
|
10
|
+
|
11
|
+
it 'require the full path as consumers will need absolute not relative paths' do
|
12
|
+
Dir.should_receive(:glob).with(File.expand_path("../../../lib/schemata/dea/advertise_message/*.rb", __FILE__))
|
13
|
+
subject
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -36,13 +36,9 @@ end
|
|
36
36
|
shared_examples "a mocking method" do |version|
|
37
37
|
|
38
38
|
context "when current_version is #{version}" do
|
39
|
-
before
|
40
|
-
set_current_version(message_type, version)
|
41
|
-
end
|
39
|
+
before { set_current_version(message_type, version) }
|
42
40
|
|
43
|
-
after
|
44
|
-
reset_version(message_type)
|
45
|
-
end
|
41
|
+
after { reset_version(message_type) }
|
46
42
|
|
47
43
|
it "should return a V#{version} object if called with no argument" do
|
48
44
|
msg_obj = component.send(mock_method)
|
@@ -58,7 +54,7 @@ shared_examples "a mocking method" do |version|
|
|
58
54
|
|
59
55
|
it "should raise an error if called with input > #{version}" do
|
60
56
|
expect {
|
61
|
-
|
57
|
+
component.send(mock_method, version + 1)
|
62
58
|
}.to raise_error(NameError)
|
63
59
|
end
|
64
60
|
end
|
@@ -23,14 +23,13 @@ shared_examples "a message" do |msg|
|
|
23
23
|
it "should raise an error if the hash contains incorrect types" do
|
24
24
|
mock_hash = component.send(mock_method, 1).contents
|
25
25
|
first_key = mock_hash.keys[0]
|
26
|
-
first_value = mock_hash[first_key]
|
27
26
|
|
28
27
|
schema = message.schema.schemas[first_key]
|
29
28
|
unallowed_classes = get_unallowed_classes(schema)
|
30
29
|
bad_value = default_value(unallowed_classes.to_a[0])
|
31
30
|
|
32
31
|
expect {
|
33
|
-
|
32
|
+
message.new(first_key => bad_value)
|
34
33
|
}.to raise_error(Schemata::UpdateAttributeError)
|
35
34
|
end
|
36
35
|
|
@@ -75,7 +74,6 @@ shared_examples "a message" do |msg|
|
|
75
74
|
end
|
76
75
|
json_hash.should have_key "min_version"
|
77
76
|
|
78
|
-
data = Schemata::Helpers.deep_copy(json_hash["V#{version}"])
|
79
77
|
1.upto(version) do |i|
|
80
78
|
json_hash.delete("V#{i}")
|
81
79
|
end
|
@@ -111,7 +109,7 @@ shared_examples "a message" do |msg|
|
|
111
109
|
it "should allow nil values during instantiation" do
|
112
110
|
mock_value = component.send(mock_method, version).contents[attr]
|
113
111
|
hash = { attr => mock_value }
|
114
|
-
|
112
|
+
expect { message.new(hash) }.not_to raise_error
|
115
113
|
end
|
116
114
|
|
117
115
|
it "should be able to set the attribute to nil" do
|
@@ -133,8 +131,6 @@ shared_examples "a message" do |msg|
|
|
133
131
|
|
134
132
|
unless msg.schema.schemas[attr].kind_of? Membrane::Schema::Any
|
135
133
|
it "should raise an error if the wrong type is written" do
|
136
|
-
mock_value = component.send(mock_method, version).contents[attr]
|
137
|
-
|
138
134
|
schema = message.schema.schemas[attr]
|
139
135
|
unallowed_classes = get_unallowed_classes(schema)
|
140
136
|
bad_value = default_value(unallowed_classes.to_a[0])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schemata-dea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta17
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -150,7 +150,9 @@ files:
|
|
150
150
|
- lib/schemata/helpers/hash_copy.rb
|
151
151
|
- lib/schemata/helpers/stringify.rb
|
152
152
|
- spec/cloud_controller_spec.rb
|
153
|
+
- spec/common/componentbase_spec.rb
|
153
154
|
- spec/common/helpers_spec.rb
|
155
|
+
- spec/common/msgtypebase_spec.rb
|
154
156
|
- spec/common/parsed_msg_spec.rb
|
155
157
|
- spec/component/aux_data_spec.rb
|
156
158
|
- spec/component/component_bar_spec.rb
|
@@ -192,7 +194,9 @@ specification_version: 3
|
|
192
194
|
summary: validation for cloundfoundry DEA messages
|
193
195
|
test_files:
|
194
196
|
- spec/cloud_controller_spec.rb
|
197
|
+
- spec/common/componentbase_spec.rb
|
195
198
|
- spec/common/helpers_spec.rb
|
199
|
+
- spec/common/msgtypebase_spec.rb
|
196
200
|
- spec/common/parsed_msg_spec.rb
|
197
201
|
- spec/component/aux_data_spec.rb
|
198
202
|
- spec/component/component_bar_spec.rb
|