cf_script 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -6
- data/CHANGELOG.md +11 -0
- data/README.md +9 -7
- data/lib/cf_script/command/base.rb +8 -4
- data/lib/cf_script/command/cf/apps.rb +4 -0
- data/lib/cf_script/command/cf/apps/restart_app_instance.rb +20 -0
- data/lib/cf_script/command/cf/apps/scale.rb +39 -0
- data/lib/cf_script/command/cf/routes/check_route.rb +1 -1
- data/lib/cf_script/command/cf/spaces/space.rb +1 -1
- data/lib/cf_script/command/registry.rb +1 -1
- data/lib/cf_script/command/runner.rb +6 -4
- data/lib/cf_script/executor/simple.rb +1 -1
- data/lib/cf_script/object/app_info.rb +8 -8
- data/lib/cf_script/output/buffer.rb +1 -1
- data/lib/cf_script/output/parser/attributes.rb +1 -1
- data/lib/cf_script/output/tests.rb +6 -6
- data/lib/cf_script/scope/app/state.rb +12 -0
- data/lib/cf_script/scope/script.rb +1 -1
- data/lib/cf_script/version.rb +1 -1
- data/test/fixtures/commands/apps/restart_app_instance/good.yml +8 -0
- data/test/fixtures/commands/apps/restart_app_instance/not_found.yml +8 -0
- data/test/fixtures/commands/apps/scale/good.yml +8 -0
- data/test/lib/cf_script/command/base_test.rb +127 -2
- data/test/lib/cf_script/command/cf/apps/app_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/delete_test.rb +1 -1
- data/test/lib/cf_script/command/cf/apps/push_test.rb +1 -1
- data/test/lib/cf_script/command/cf/apps/rename_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/restage_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/restart_app_instance_test.rb +41 -0
- data/test/lib/cf_script/command/cf/apps/restart_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/scale_test.rb +51 -0
- data/test/lib/cf_script/command/cf/apps/set_env_test.rb +1 -1
- data/test/lib/cf_script/command/cf/apps/start_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/stop_test.rb +2 -2
- data/test/lib/cf_script/command/cf/apps/unset_env_test.rb +1 -1
- data/test/lib/cf_script/command/cf/general/api_test.rb +3 -3
- data/test/lib/cf_script/command/cf/general/target_test.rb +2 -2
- data/test/lib/cf_script/command/cf/routes/map_route_test.rb +6 -6
- data/test/lib/cf_script/command/cf/routes/routes_test.rb +1 -1
- data/test/lib/cf_script/command/cf/spaces/space_test.rb +1 -1
- data/test/lib/cf_script/command/cf/spaces/spaces_test.rb +1 -1
- data/test/lib/cf_script/command/line_test.rb +16 -8
- data/test/lib/cf_script/command/registry_test.rb +53 -0
- data/test/lib/cf_script/object/api_endpoint_test.rb +2 -2
- data/test/lib/cf_script/object/app_info_test.rb +13 -13
- data/test/lib/cf_script/object/instance_status_test.rb +7 -7
- data/test/lib/cf_script/object/space_test.rb +1 -1
- data/test/lib/cf_script/object/target_test.rb +1 -1
- data/test/lib/cf_script/output/buffer_test.rb +1 -1
- data/test/lib/cf_script/output/parser/section_test.rb +1 -1
- data/test/lib/cf_script/output/parser/table_test.rb +1 -1
- data/test/lib/cf_script/scope/app/state_test.rb +34 -0
- data/test/lib/cf_script/scope/app_test.rb +5 -1
- data/test/lib/cf_script/ui_test.rb +3 -3
- data/test/support/helpers/object_helpers.rb +4 -4
- data/test/support/shared_examples/command_object.rb +17 -3
- metadata +14 -3
@@ -42,15 +42,15 @@ describe CfScript::AppInfo do
|
|
42
42
|
info = CfScript::AppInfo.new('name', empty_attrs)
|
43
43
|
|
44
44
|
assert_equal 'name', info.name
|
45
|
-
|
46
|
-
|
45
|
+
assert_nil info.requested_state
|
46
|
+
assert_nil info.instances
|
47
47
|
assert_equal [], info.urls
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
assert_nil info.usage
|
49
|
+
assert_nil info.last_uploaded
|
50
|
+
assert_nil info.stack
|
51
|
+
assert_nil info.buildpack
|
52
|
+
assert_nil info.memory
|
53
|
+
assert_nil info.disk
|
54
54
|
end
|
55
55
|
|
56
56
|
it "sets apps command attributes when given" do
|
@@ -62,10 +62,10 @@ describe CfScript::AppInfo do
|
|
62
62
|
assert_equal 2, info.urls.length
|
63
63
|
assert_equal 'projects.example.com', info.urls.first
|
64
64
|
assert_equal 'projects.example.io', info.urls.last
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
assert_nil info.usage
|
66
|
+
assert_nil info.last_uploaded
|
67
|
+
assert_nil info.stack
|
68
|
+
assert_nil info.buildpack
|
69
69
|
assert_equal '1G', info.memory
|
70
70
|
assert_equal '2G', info.disk
|
71
71
|
end
|
@@ -84,7 +84,7 @@ describe CfScript::AppInfo do
|
|
84
84
|
assert_equal 'cflinuxfs2', info.stack
|
85
85
|
assert_equal buildpack, info.buildpack
|
86
86
|
assert_equal '1G', info.memory # Extracted from usage
|
87
|
-
|
87
|
+
assert_nil info.disk
|
88
88
|
end
|
89
89
|
|
90
90
|
it "defines state method that return value of requested_state" do
|
@@ -12,13 +12,13 @@ describe CfScript::InstanceStatus do
|
|
12
12
|
it "initializes all attributes to sensible defaults" do
|
13
13
|
status = CfScript::InstanceStatus.new
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
assert_nil status.index
|
16
|
+
assert_nil status.state
|
17
|
+
assert_nil status.since
|
18
|
+
assert_nil status.cpu
|
19
|
+
assert_nil status.memory
|
20
|
+
assert_nil status.disk
|
21
|
+
assert_nil status.details
|
22
22
|
end
|
23
23
|
|
24
24
|
it "initializes given attributes" do
|
@@ -53,7 +53,7 @@ describe CfScript::Output::Buffer do
|
|
53
53
|
|
54
54
|
it "responds to match and returns MatchData object" do
|
55
55
|
assert_instance_of MatchData, buffer.match(/2/)
|
56
|
-
|
56
|
+
assert_nil buffer.match(/4/)
|
57
57
|
end
|
58
58
|
|
59
59
|
it "responds to matches? and returns true or false" do
|
@@ -88,4 +88,38 @@ describe CfScript::Scope::App::State do
|
|
88
88
|
assert_equal :called, app.restage
|
89
89
|
end
|
90
90
|
end
|
91
|
+
|
92
|
+
it "defines a scale method that calls Command.scale with the app name and options" do
|
93
|
+
app = create_app(:api)
|
94
|
+
|
95
|
+
arg_catcher = lambda do |command, *args, &block|
|
96
|
+
assert_equal :scale, command
|
97
|
+
assert_equal [:api, { i: 4, k: '256M', m: '128M' }], args
|
98
|
+
|
99
|
+
return :called
|
100
|
+
end
|
101
|
+
|
102
|
+
app.stub :cf_self, true do
|
103
|
+
CfScript::Command.stub :run, arg_catcher do
|
104
|
+
assert_equal :called, app.scale(i: 4, k: '256M', m: '128M')
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
it "defines a restart_instance method that calls Command.restart_app_instance with the app name and an instance index" do
|
110
|
+
app = create_app(:api)
|
111
|
+
|
112
|
+
arg_catcher = lambda do |command, *args, &block|
|
113
|
+
assert_equal :restart_app_instance, command
|
114
|
+
assert_equal [:api, 0], args
|
115
|
+
|
116
|
+
return :called
|
117
|
+
end
|
118
|
+
|
119
|
+
app.stub :cf_self, true do
|
120
|
+
CfScript::Command.stub :run, arg_catcher do
|
121
|
+
assert_equal :called, app.restart_instance(0)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
91
125
|
end
|
@@ -36,7 +36,7 @@ describe CfScript::Scope::App do
|
|
36
36
|
it "raises if initialized with anything other than a name or AppInfo" do
|
37
37
|
assert_raises(RuntimeError) {
|
38
38
|
fake_cf do
|
39
|
-
|
39
|
+
CfScript::Scope::App.new([], target)
|
40
40
|
end
|
41
41
|
}
|
42
42
|
end
|
@@ -79,7 +79,11 @@ describe CfScript::Scope::App do
|
|
79
79
|
it "includes the App::State module" do
|
80
80
|
assert_respond_to subject, :start
|
81
81
|
assert_respond_to subject, :stop
|
82
|
+
assert_respond_to subject, :restart
|
82
83
|
assert_respond_to subject, :push
|
84
|
+
assert_respond_to subject, :restage
|
85
|
+
assert_respond_to subject, :scale
|
86
|
+
assert_respond_to subject, :restart_instance
|
83
87
|
end
|
84
88
|
|
85
89
|
it "includes the App::Env module" do
|
@@ -84,7 +84,7 @@ describe CfScript::UI do
|
|
84
84
|
with_config do
|
85
85
|
emoji = subject.emoji_for(:success)
|
86
86
|
|
87
|
-
|
87
|
+
assert_nil emoji
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -102,7 +102,7 @@ describe CfScript::UI do
|
|
102
102
|
with_config tags: false do
|
103
103
|
tag = subject.tag_format('foo', :trace)
|
104
104
|
|
105
|
-
|
105
|
+
assert_nil tag
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -110,7 +110,7 @@ describe CfScript::UI do
|
|
110
110
|
with_config tags: true do
|
111
111
|
tag = subject.tag_format(nil, :trace)
|
112
112
|
|
113
|
-
|
113
|
+
assert_nil tag
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
@@ -10,13 +10,13 @@ module ObjectHelpers
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def build_instance_status_attrs(options = {})
|
13
|
-
|
13
|
+
build_attribute_list({
|
14
14
|
index: '0',
|
15
15
|
state: '1',
|
16
16
|
since: '2',
|
17
|
-
cpu:
|
17
|
+
cpu: '3',
|
18
18
|
memory: '4',
|
19
|
-
disk:
|
19
|
+
disk: '5',
|
20
20
|
details: '6'
|
21
21
|
}.merge(options))
|
22
22
|
end
|
@@ -24,6 +24,6 @@ module ObjectHelpers
|
|
24
24
|
def build_instance_status(options = {})
|
25
25
|
attrs = build_instance_status_attrs(options)
|
26
26
|
|
27
|
-
|
27
|
+
CfScript::InstanceStatus.new(attrs)
|
28
28
|
end
|
29
29
|
end
|
@@ -14,7 +14,11 @@ shared_examples_for 'a command object that' do |attrs|
|
|
14
14
|
fake_cf attrs[:has_name] => :fail do
|
15
15
|
args = fake_command_args(command)
|
16
16
|
|
17
|
-
|
17
|
+
if attrs[:fails_with].nil?
|
18
|
+
assert_nil command.run(*args)
|
19
|
+
else
|
20
|
+
assert_equal attrs[:fails_with], command.run(*args)
|
21
|
+
end
|
18
22
|
end
|
19
23
|
end
|
20
24
|
|
@@ -22,7 +26,12 @@ shared_examples_for 'a command object that' do |attrs|
|
|
22
26
|
fake_cf attrs[:has_name] => :no_endpoint do |stdout, stderr|
|
23
27
|
args = fake_command_args(command)
|
24
28
|
|
25
|
-
|
29
|
+
if attrs[:fails_with].nil?
|
30
|
+
assert_nil command.run(*args)
|
31
|
+
else
|
32
|
+
assert_equal attrs[:fails_with], command.run(*args)
|
33
|
+
end
|
34
|
+
|
26
35
|
assert_includes stderr.lines, "{#{attrs[:has_name]}} No API endpoint set\n"
|
27
36
|
end
|
28
37
|
end
|
@@ -31,7 +40,12 @@ shared_examples_for 'a command object that' do |attrs|
|
|
31
40
|
fake_cf attrs[:has_name] => :no_login do |stdout, stderr|
|
32
41
|
args = fake_command_args(command)
|
33
42
|
|
34
|
-
|
43
|
+
if attrs[:fails_with].nil?
|
44
|
+
assert_nil command.run(*args)
|
45
|
+
else
|
46
|
+
assert_equal attrs[:fails_with], command.run(*args)
|
47
|
+
end
|
48
|
+
|
35
49
|
assert_includes stderr.lines, "{#{attrs[:has_name]}} Not logged in\n"
|
36
50
|
end
|
37
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf_script
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ammar Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -51,6 +51,8 @@ files:
|
|
51
51
|
- lib/cf_script/command/cf/apps/rename.rb
|
52
52
|
- lib/cf_script/command/cf/apps/restage.rb
|
53
53
|
- lib/cf_script/command/cf/apps/restart.rb
|
54
|
+
- lib/cf_script/command/cf/apps/restart_app_instance.rb
|
55
|
+
- lib/cf_script/command/cf/apps/scale.rb
|
54
56
|
- lib/cf_script/command/cf/apps/set_env.rb
|
55
57
|
- lib/cf_script/command/cf/apps/start.rb
|
56
58
|
- lib/cf_script/command/cf/apps/stop.rb
|
@@ -127,6 +129,9 @@ files:
|
|
127
129
|
- test/fixtures/commands/apps/restage/not_found.yml
|
128
130
|
- test/fixtures/commands/apps/restart/good.yml
|
129
131
|
- test/fixtures/commands/apps/restart/not_found.yml
|
132
|
+
- test/fixtures/commands/apps/restart_app_instance/good.yml
|
133
|
+
- test/fixtures/commands/apps/restart_app_instance/not_found.yml
|
134
|
+
- test/fixtures/commands/apps/scale/good.yml
|
130
135
|
- test/fixtures/commands/apps/set_env/good.yml
|
131
136
|
- test/fixtures/commands/apps/set_env/not_found.yml
|
132
137
|
- test/fixtures/commands/apps/start/good.yml
|
@@ -184,7 +189,9 @@ files:
|
|
184
189
|
- test/lib/cf_script/command/cf/apps/push_test.rb
|
185
190
|
- test/lib/cf_script/command/cf/apps/rename_test.rb
|
186
191
|
- test/lib/cf_script/command/cf/apps/restage_test.rb
|
192
|
+
- test/lib/cf_script/command/cf/apps/restart_app_instance_test.rb
|
187
193
|
- test/lib/cf_script/command/cf/apps/restart_test.rb
|
194
|
+
- test/lib/cf_script/command/cf/apps/scale_test.rb
|
188
195
|
- test/lib/cf_script/command/cf/apps/set_env_test.rb
|
189
196
|
- test/lib/cf_script/command/cf/apps/start_test.rb
|
190
197
|
- test/lib/cf_script/command/cf/apps/stop_test.rb
|
@@ -203,6 +210,7 @@ files:
|
|
203
210
|
- test/lib/cf_script/command/cf/spaces/space_test.rb
|
204
211
|
- test/lib/cf_script/command/cf/spaces/spaces_test.rb
|
205
212
|
- test/lib/cf_script/command/line_test.rb
|
213
|
+
- test/lib/cf_script/command/registry_test.rb
|
206
214
|
- test/lib/cf_script/object/api_endpoint_test.rb
|
207
215
|
- test/lib/cf_script/object/app_info_test.rb
|
208
216
|
- test/lib/cf_script/object/app_list_test.rb
|
@@ -261,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
269
|
version: '0'
|
262
270
|
requirements: []
|
263
271
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.
|
272
|
+
rubygems_version: 2.6.8
|
265
273
|
signing_key:
|
266
274
|
specification_version: 4
|
267
275
|
summary: A DSL for scripting the Cloud Foundry CLI
|
@@ -274,7 +282,9 @@ test_files:
|
|
274
282
|
- test/lib/cf_script/command/cf/apps/push_test.rb
|
275
283
|
- test/lib/cf_script/command/cf/apps/rename_test.rb
|
276
284
|
- test/lib/cf_script/command/cf/apps/restage_test.rb
|
285
|
+
- test/lib/cf_script/command/cf/apps/restart_app_instance_test.rb
|
277
286
|
- test/lib/cf_script/command/cf/apps/restart_test.rb
|
287
|
+
- test/lib/cf_script/command/cf/apps/scale_test.rb
|
278
288
|
- test/lib/cf_script/command/cf/apps/set_env_test.rb
|
279
289
|
- test/lib/cf_script/command/cf/apps/start_test.rb
|
280
290
|
- test/lib/cf_script/command/cf/apps/stop_test.rb
|
@@ -293,6 +303,7 @@ test_files:
|
|
293
303
|
- test/lib/cf_script/command/cf/spaces/space_test.rb
|
294
304
|
- test/lib/cf_script/command/cf/spaces/spaces_test.rb
|
295
305
|
- test/lib/cf_script/command/line_test.rb
|
306
|
+
- test/lib/cf_script/command/registry_test.rb
|
296
307
|
- test/lib/cf_script/object/api_endpoint_test.rb
|
297
308
|
- test/lib/cf_script/object/app_info_test.rb
|
298
309
|
- test/lib/cf_script/object/app_list_test.rb
|