cf_script 0.0.1.beta.1 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +18 -0
- data/README.md +182 -34
- data/Rakefile +0 -13
- data/lib/cf_script/command/base.rb +1 -1
- data/lib/cf_script/command/cf/apps/app.rb +1 -1
- data/lib/cf_script/command/cf/apps/apps.rb +5 -3
- data/lib/cf_script/command/cf/apps/delete.rb +25 -0
- data/lib/cf_script/command/cf/apps/env.rb +4 -2
- data/lib/cf_script/command/cf/apps/push.rb +7 -2
- data/lib/cf_script/command/cf/apps/rename.rb +20 -0
- data/lib/cf_script/command/cf/apps/restage.rb +1 -1
- data/lib/cf_script/command/cf/apps/restart.rb +1 -1
- data/lib/cf_script/command/cf/apps/set_env.rb +1 -1
- data/lib/cf_script/command/cf/apps/start.rb +1 -1
- data/lib/cf_script/command/cf/apps/stop.rb +3 -2
- data/lib/cf_script/command/cf/apps/unset_env.rb +1 -1
- data/lib/cf_script/command/cf/apps.rb +5 -1
- data/lib/cf_script/command/cf/general/api.rb +1 -1
- data/lib/cf_script/command/cf/general/auth.rb +1 -1
- data/lib/cf_script/command/cf/general/login.rb +1 -1
- data/lib/cf_script/command/cf/general/logout.rb +1 -1
- data/lib/cf_script/command/cf/general/target.rb +1 -1
- data/lib/cf_script/command/cf/routes/check_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/create_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/delete_route.rb +5 -2
- data/lib/cf_script/command/cf/routes/map_route.rb +1 -1
- data/lib/cf_script/command/cf/routes/routes.rb +1 -1
- data/lib/cf_script/command/cf/routes/unmap_route.rb +1 -1
- data/lib/cf_script/command/cf/spaces/space.rb +1 -1
- data/lib/cf_script/command/cf/spaces/spaces.rb +1 -1
- data/lib/cf_script/command/runner.rb +1 -15
- data/lib/cf_script/config.rb +3 -1
- data/lib/cf_script/executor/recorder.rb +3 -1
- data/lib/cf_script/executor/simple.rb +22 -9
- data/lib/cf_script/executor.rb +0 -1
- data/lib/cf_script/object/api_endpoint.rb +1 -1
- data/lib/cf_script/object/app_info.rb +1 -1
- data/lib/cf_script/object/app_list.rb +21 -5
- data/lib/cf_script/object/attribute.rb +1 -1
- data/lib/cf_script/object/attribute_list.rb +1 -1
- data/lib/cf_script/object/instance_status.rb +1 -1
- data/lib/cf_script/object/route_info.rb +1 -1
- data/lib/cf_script/object/space.rb +1 -1
- data/lib/cf_script/object/target.rb +1 -1
- data/lib/cf_script/object.rb +0 -11
- data/lib/cf_script/output/buffer.rb +1 -1
- data/lib/cf_script/scope/app/routes.rb +1 -1
- data/lib/cf_script/scope/app.rb +0 -26
- data/lib/cf_script/scope/target.rb +7 -1
- data/lib/cf_script/ui.rb +2 -6
- data/lib/cf_script/version.rb +1 -1
- data/lib/cf_script.rb +0 -2
- data/test/fixtures/commands/apps/delete/good.yml +8 -0
- data/test/fixtures/commands/apps/delete/not_exist.yml +9 -0
- data/test/fixtures/commands/apps/env/{empty.yml → empty_vars.yml} +0 -0
- data/test/fixtures/commands/apps/rename/good.yml +8 -0
- data/test/fixtures/commands/apps/rename/not_found.yml +8 -0
- data/test/fixtures/commands/{apps/set_env → common}/empty.yml +0 -0
- data/test/lib/cf_script/command/cf/apps/app_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/apps_test.rb +12 -3
- data/test/lib/cf_script/command/cf/apps/delete_test.rb +51 -0
- data/test/lib/cf_script/command/cf/apps/env_test.rb +12 -2
- data/test/lib/cf_script/command/cf/apps/push_test.rb +14 -0
- data/test/lib/cf_script/command/cf/apps/rename_test.rb +35 -0
- data/test/lib/cf_script/command/cf/apps/restage_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/restart_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/start_test.rb +8 -0
- data/test/lib/cf_script/command/cf/apps/stop_test.rb +2 -2
- data/test/lib/cf_script/command/cf/general/login_test.rb +9 -10
- data/test/lib/cf_script/command/cf/routes/create_route_test.rb +12 -0
- data/test/lib/cf_script/command/cf/routes/delete_route_test.rb +18 -0
- data/test/lib/cf_script/command/cf/routes/map_route_test.rb +12 -0
- data/test/lib/cf_script/command/cf/routes/routes_test.rb +8 -0
- data/test/lib/cf_script/command/cf/routes/unmap_route_test.rb +12 -0
- data/test/lib/cf_script/object/app_info_test.rb +4 -4
- data/test/lib/cf_script/object/app_list_test.rb +68 -2
- data/test/lib/cf_script/output/buffer_test.rb +9 -9
- data/test/lib/cf_script/output/parser/section_test.rb +4 -2
- data/test/lib/cf_script/output/tests_test.rb +24 -24
- data/test/lib/cf_script/output_test.rb +23 -18
- data/test/lib/cf_script/scope/app/env_test.rb +58 -0
- data/test/lib/cf_script/scope/app/routes_test.rb +56 -0
- data/test/lib/cf_script/scope/app/state_test.rb +30 -0
- data/test/lib/cf_script/scope/script_test.rb +3 -2
- data/test/lib/cf_script/scope/target_test.rb +38 -23
- data/test/lib/cf_script/scope_test.rb +10 -6
- data/test/lib/cf_script/ui_test.rb +133 -0
- data/test/lib/cf_script_test.rb +14 -8
- data/test/support/assertions.rb +25 -0
- data/test/support/helpers/fixture_executor.rb +1 -1
- data/test/support/helpers/mock_execution.rb +29 -7
- metadata +23 -14
- data/lib/cf_script/callbacks.rb +0 -43
- data/lib/cf_script/executor/non_blocking.rb +0 -107
- data/lib/cf_script/object/app_spec.rb +0 -55
- data/test/fixtures/commands/apps/unset_env/empty.yml +0 -5
- data/test/fixtures/commands/general/auth/empty.yml +0 -5
- data/test/fixtures/commands/general/target/empty.yml +0 -5
- data/test/fixtures/commands/spaces/space/empty.yml +0 -5
- data/test/fixtures/commands/spaces/spaces/empty.yml +0 -5
@@ -24,16 +24,15 @@ describe 'LoginCommand' do
|
|
24
24
|
space: 'staging'
|
25
25
|
}
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
27
|
+
assert_command_args command,
|
28
|
+
['user', 'pass', options],
|
29
|
+
[{
|
30
|
+
u: 'user',
|
31
|
+
p: 'pass',
|
32
|
+
a: 'https://api.example.io',
|
33
|
+
o: 'ACME',
|
34
|
+
s: 'staging'
|
35
|
+
}]
|
37
36
|
end
|
38
37
|
|
39
38
|
it "returns false when credentials get rejected" do
|
@@ -16,4 +16,16 @@ describe 'CreateRouteCommand' do
|
|
16
16
|
assert_equal true, command.run(:staging, :api, 'example.com')
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
it "host option defaults to nil" do
|
21
|
+
assert_command_args command,
|
22
|
+
[:staging, 'example.com'],
|
23
|
+
[:staging, 'example.com', {}]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "adds option for host when given" do
|
27
|
+
assert_command_args command,
|
28
|
+
[:staging, 'example.com', 'www'],
|
29
|
+
[:staging, 'example.com', { n: 'www' }]
|
30
|
+
end
|
19
31
|
end
|
@@ -16,4 +16,22 @@ describe 'DeleteRouteCommand' do
|
|
16
16
|
assert_equal true, command.run('example.com', :api)
|
17
17
|
end
|
18
18
|
end
|
19
|
+
|
20
|
+
it "adds flag for force by default" do
|
21
|
+
assert_command_args command,
|
22
|
+
['example.com'],
|
23
|
+
['example.com', { flags: [:f] }]
|
24
|
+
end
|
25
|
+
|
26
|
+
it "skips flag for force when false" do
|
27
|
+
assert_command_args command,
|
28
|
+
['example.com', 'www', false],
|
29
|
+
['example.com', { n: 'www' }]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "adds option for host and flag for force when both are given" do
|
33
|
+
assert_command_args command,
|
34
|
+
['example.com', 'www', true],
|
35
|
+
['example.com', { n: 'www', flags: [:f] }]
|
36
|
+
end
|
19
37
|
end
|
@@ -18,6 +18,18 @@ describe 'MapRouteCommand' do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
it "host option defaults to nil" do
|
22
|
+
assert_command_args command,
|
23
|
+
[:worker, 'example.com'],
|
24
|
+
[:worker, 'example.com', {}]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "adds option for host when given" do
|
28
|
+
assert_command_args command,
|
29
|
+
[:worker, 'example.com', 'www'],
|
30
|
+
[:worker, 'example.com', { n: 'www' }]
|
31
|
+
end
|
32
|
+
|
21
33
|
it "prints an error and returns false when the route is invalid" do
|
22
34
|
fake_cf map_route: :invalid do |stdout, stderr|
|
23
35
|
assert_equal false, command.run(:api, 'example.com')
|
@@ -18,6 +18,18 @@ describe 'UnmapRouteCommand' do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
it "host option defaults to nil" do
|
22
|
+
assert_command_args command,
|
23
|
+
[:worker, 'example.com'],
|
24
|
+
[:worker, 'example.com', {}]
|
25
|
+
end
|
26
|
+
|
27
|
+
it "adds option for host when given" do
|
28
|
+
assert_command_args command,
|
29
|
+
[:worker, 'example.com', 'www'],
|
30
|
+
[:worker, 'example.com', { n: 'www' }]
|
31
|
+
end
|
32
|
+
|
21
33
|
it "prints an error and returns false when the app can not be found" do
|
22
34
|
fake_cf unmap_route: :no_app do |stdout, stderr|
|
23
35
|
assert_equal false, command.run(:api, 'example.com')
|
@@ -103,11 +103,11 @@ describe CfScript::AppInfo do
|
|
103
103
|
assert_respond_to info, :stopped?
|
104
104
|
assert_respond_to info, :cold?
|
105
105
|
|
106
|
-
|
107
|
-
|
106
|
+
assert_equal true, info.started?
|
107
|
+
assert_equal true, info.hot?
|
108
108
|
|
109
|
-
|
110
|
-
|
109
|
+
refute_equal true, info.stopped?
|
110
|
+
refute_equal true, info.cold?
|
111
111
|
end
|
112
112
|
|
113
113
|
it "defines set_intance_status method that takes attribute lists and builds InstanceStatus objects" do
|
@@ -16,9 +16,15 @@ describe CfScript::AppList do
|
|
16
16
|
urls: 'example.com',
|
17
17
|
)
|
18
18
|
|
19
|
+
api_attrs = build_attribute_list(
|
20
|
+
requested_state: 'started',
|
21
|
+
urls: 'example.com',
|
22
|
+
)
|
23
|
+
|
19
24
|
@list = CfScript::AppList.new([
|
20
25
|
CfScript::AppInfo.new('one-worker', one_attrs),
|
21
26
|
CfScript::AppInfo.new('two-engine', two_attrs),
|
27
|
+
CfScript::AppInfo.new('org-api', api_attrs),
|
22
28
|
])
|
23
29
|
end
|
24
30
|
|
@@ -28,14 +34,74 @@ describe CfScript::AppList do
|
|
28
34
|
assert_equal 0, app_list.length
|
29
35
|
end
|
30
36
|
|
31
|
-
it "
|
37
|
+
it "defines a names method that returns an array of names" do
|
38
|
+
assert_instance_of Array, list.names
|
39
|
+
assert_equal ['one-worker', 'two-engine', 'org-api'], list.names
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '==' do
|
43
|
+
it "returns true when the lists contain the same names" do
|
44
|
+
other = CfScript::AppList.new([
|
45
|
+
CfScript::AppInfo.new('one-worker', {}),
|
46
|
+
CfScript::AppInfo.new('two-engine', {}),
|
47
|
+
CfScript::AppInfo.new('org-api', {}),
|
48
|
+
])
|
49
|
+
|
50
|
+
assert_equal true, other == list
|
51
|
+
end
|
52
|
+
|
53
|
+
it "returns false when the lists have different names" do
|
54
|
+
other = CfScript::AppList.new([
|
55
|
+
CfScript::AppInfo.new('one-engine', {}),
|
56
|
+
CfScript::AppInfo.new('two-worker', {}),
|
57
|
+
CfScript::AppInfo.new('org-api', {}),
|
58
|
+
])
|
59
|
+
|
60
|
+
assert_equal false, other == list
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe 'each_name' do
|
65
|
+
it "yields the app name in the list" do
|
66
|
+
names = []
|
67
|
+
|
68
|
+
list.each_name do |name|
|
69
|
+
names << name
|
70
|
+
end
|
71
|
+
|
72
|
+
assert_equal names, list.names
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'each' do
|
77
|
+
it "yields each AppInfo instance in the list" do
|
78
|
+
infos = []
|
79
|
+
|
80
|
+
list.each do |info|
|
81
|
+
infos << info
|
82
|
+
end
|
83
|
+
|
84
|
+
infos.each_with_index do |info, index|
|
85
|
+
assert_equal info, list[index]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it "selects by suffix" do
|
32
91
|
list.select!(ending_with: 'worker')
|
33
92
|
|
34
93
|
assert_equal 1, list.length
|
35
94
|
assert_equal 'one-worker', list.first.name
|
36
95
|
end
|
37
96
|
|
38
|
-
it "selects by
|
97
|
+
it "selects by matching" do
|
98
|
+
list.select!(matching: 'api')
|
99
|
+
|
100
|
+
assert_equal 1, list.length
|
101
|
+
assert_equal 'org-api', list.first.name
|
102
|
+
end
|
103
|
+
|
104
|
+
it "selects by prefix" do
|
39
105
|
list.select!(starting_with: 'two')
|
40
106
|
|
41
107
|
assert_equal 1, list.length
|
@@ -13,17 +13,17 @@ describe CfScript::Output::Buffer do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "responds to raw and returns a original text" do
|
16
|
-
assert buffer.respond_to?(:raw)
|
16
|
+
assert buffer.respond_to?(:raw), "Expected Buffer to respond to raw"
|
17
17
|
assert_equal raw_text, buffer.raw
|
18
18
|
end
|
19
19
|
|
20
20
|
it "responds to content and returns a sanitized copy" do
|
21
|
-
assert buffer.respond_to?(:content)
|
21
|
+
assert buffer.respond_to?(:content), "Expected Buffer to respond to content"
|
22
22
|
assert_equal "line 1\nline 2\nline 3\n", buffer.content
|
23
23
|
end
|
24
24
|
|
25
25
|
it "responds to lines and returns sanitized lines" do
|
26
|
-
assert buffer.respond_to?(:lines)
|
26
|
+
assert buffer.respond_to?(:lines), "Expected Buffer to respond to lines"
|
27
27
|
assert_equal ['line 1', 'line 2', 'line 3'], buffer.lines
|
28
28
|
end
|
29
29
|
|
@@ -57,17 +57,17 @@ describe CfScript::Output::Buffer do
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it "responds to matches? and returns true or false" do
|
60
|
-
|
61
|
-
|
60
|
+
assert_equal true, buffer.matches?(/2/)
|
61
|
+
refute_equal true, buffer.matches?(/4/)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "responds to contains? and returns true or false" do
|
65
|
-
|
66
|
-
|
65
|
+
assert_equal true, buffer.contains?('2')
|
66
|
+
refute_equal true, buffer.contains?('4')
|
67
67
|
end
|
68
68
|
|
69
69
|
it "responds to last_line_matches? and returns true or false" do
|
70
|
-
|
71
|
-
|
70
|
+
assert_equal true, buffer.last_line_matches?(/3/)
|
71
|
+
refute_equal true, buffer.last_line_matches?(/4/)
|
72
72
|
end
|
73
73
|
end
|
@@ -33,8 +33,10 @@ describe CfScript::Output::Parser::Section do
|
|
33
33
|
|
34
34
|
describe "parse_section_attributes" do
|
35
35
|
it "calls parse_attribute_list" do
|
36
|
-
parser.stub :parse_attribute_list,
|
37
|
-
assert_equal
|
36
|
+
parser.stub :parse_attribute_list, :called do
|
37
|
+
assert_equal :called, parser.parse_section_attributes(
|
38
|
+
text_buffer, 'Section Title'
|
39
|
+
)
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -6,86 +6,86 @@ describe CfScript::Output::Tests do
|
|
6
6
|
it "defines matches? and calls the out buffer matches?" do
|
7
7
|
output = fake_output
|
8
8
|
|
9
|
-
output.out.stub :matches?,
|
10
|
-
assert_equal
|
9
|
+
output.out.stub :matches?, :called do
|
10
|
+
assert_equal :called, output.matches?('a')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
it "defines contains? and calls the out buffer matches?" do
|
15
15
|
output = fake_output
|
16
16
|
|
17
|
-
output.out.stub :contains?,
|
18
|
-
assert_equal
|
17
|
+
output.out.stub :contains?, :called do
|
18
|
+
assert_equal :called, output.contains?('a')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
it "defines ok?, calls the out buffer last_line_matches?" do
|
23
23
|
output = fake_output('OK')
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
assert_equal true, output.ok?
|
26
|
+
refute_equal true, fake_output('KO').ok?
|
27
27
|
end
|
28
28
|
|
29
29
|
it "defines authenticated? and calls matches?" do
|
30
30
|
output = fake_output("Authenticating...\nOK")
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
assert_equal true, output.authenticated?
|
33
|
+
refute_equal true, fake_output('NOPE').authenticated?
|
34
34
|
end
|
35
35
|
|
36
36
|
it "defines failed? and calls contains?" do
|
37
37
|
output = fake_output("FAILED")
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
assert_equal true, output.failed?
|
40
|
+
refute_equal true, fake_output('OK').failed?
|
41
41
|
end
|
42
42
|
|
43
43
|
it "defines no_api_endpoint? and calls contains?" do
|
44
44
|
output = fake_output("No API endpoint set.")
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
assert_equal true, output.no_api_endpoint?
|
47
|
+
refute_equal true, fake_output('API endpoint set').no_api_endpoint?
|
48
48
|
end
|
49
49
|
|
50
50
|
it "defines not_logged_in? and calls contains?" do
|
51
51
|
output = fake_output("Not logged in")
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
assert_equal true, output.not_logged_in?
|
54
|
+
refute_equal true, fake_output('logged in').not_logged_in?
|
55
55
|
end
|
56
56
|
|
57
57
|
it "defines not_authorized? and calls contains?" do
|
58
58
|
output = fake_output("You are not authorized")
|
59
59
|
|
60
|
-
|
61
|
-
|
60
|
+
assert_equal true, output.not_authorized?
|
61
|
+
refute_equal true, fake_output('You are authorized').not_authorized?
|
62
62
|
end
|
63
63
|
|
64
64
|
it "defines credentials_rejected? and calls contains?" do
|
65
65
|
output = fake_output("Credentials were rejected")
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
assert_equal true, output.credentials_rejected?
|
68
|
+
refute_equal true, fake_output('Credentials accepted').credentials_rejected?
|
69
69
|
end
|
70
70
|
|
71
71
|
it "defines not_found? and calls out buffer's last_line_matches?" do
|
72
72
|
output = fake_output("App api not found")
|
73
73
|
|
74
|
-
|
75
|
-
|
74
|
+
assert_equal true, output.not_found?('App', 'api')
|
75
|
+
refute_equal true, fake_output('Found').not_found?('App', 'api')
|
76
76
|
end
|
77
77
|
|
78
78
|
it "defines is_already? and calls out buffer's last_line_matches?" do
|
79
79
|
output = fake_output("app is already started")
|
80
80
|
|
81
|
-
|
82
|
-
|
81
|
+
assert_equal true, output.is_already?('app', 'started')
|
82
|
+
refute_equal true, fake_output('app not started').is_already?('app', 'started')
|
83
83
|
end
|
84
84
|
|
85
85
|
it "defines already_exists? and calls out buffer's last_line_matches?" do
|
86
86
|
output = fake_output("App api already exists")
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
assert_equal true, output.already_exists?('App', 'api')
|
89
|
+
refute_equal true, fake_output('App api does not exist').already_exists?('App', 'api')
|
90
90
|
end
|
91
91
|
end
|
@@ -21,12 +21,12 @@ describe CfScript::Output do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "responds to good? and returns true if exit status == 0" do
|
24
|
-
assert output.respond_to?(:good?)
|
25
|
-
|
24
|
+
assert output.respond_to?(:good?), "Expected Output to respond to good?"
|
25
|
+
assert_equal true, output.good?
|
26
26
|
end
|
27
27
|
|
28
28
|
it "responds to good? and returns false if exit status != 0" do
|
29
|
-
|
29
|
+
refute_equal true, fake_output('', '', 1).good?
|
30
30
|
end
|
31
31
|
|
32
32
|
it "responds to out and returns a Buffer object" do
|
@@ -43,10 +43,11 @@ describe CfScript::Output do
|
|
43
43
|
|
44
44
|
describe "attributes" do
|
45
45
|
it "calls parse_attribute_list" do
|
46
|
-
assert output.respond_to?(:attributes)
|
46
|
+
assert output.respond_to?(:attributes),
|
47
|
+
"Expected Output to respond to attributes"
|
47
48
|
|
48
|
-
output.stub :parse_attribute_list,
|
49
|
-
assert_equal
|
49
|
+
output.stub :parse_attribute_list, :called do
|
50
|
+
assert_equal :called, output.attributes
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
@@ -58,10 +59,11 @@ describe CfScript::Output do
|
|
58
59
|
|
59
60
|
describe "line_attributes" do
|
60
61
|
it "calls parse_line_attributes" do
|
61
|
-
assert output.respond_to?(:line_attributes)
|
62
|
+
assert output.respond_to?(:line_attributes),
|
63
|
+
"Expected Output to respond to line_attributes"
|
62
64
|
|
63
|
-
output.stub :parse_line_attributes,
|
64
|
-
assert_equal
|
65
|
+
output.stub :parse_line_attributes, :called do
|
66
|
+
assert_equal :called, output.line_attributes(/a/)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
@@ -87,10 +89,11 @@ describe CfScript::Output do
|
|
87
89
|
end
|
88
90
|
|
89
91
|
it "calls parse_attribute_list" do
|
90
|
-
assert output.respond_to?(:attributes_from)
|
92
|
+
assert output.respond_to?(:attributes_from),
|
93
|
+
"Expected Output to respond to attributes_from"
|
91
94
|
|
92
|
-
output.stub :parse_attribute_list,
|
93
|
-
assert_equal
|
95
|
+
output.stub :parse_attribute_list, :called do
|
96
|
+
assert_equal :called, output.attributes_from('two')
|
94
97
|
end
|
95
98
|
end
|
96
99
|
|
@@ -106,10 +109,11 @@ describe CfScript::Output do
|
|
106
109
|
|
107
110
|
describe "table" do
|
108
111
|
it "calls parse_table" do
|
109
|
-
assert output.respond_to?(:table)
|
112
|
+
assert output.respond_to?(:table),
|
113
|
+
"Expected Output to respond to table"
|
110
114
|
|
111
|
-
output.stub :parse_table,
|
112
|
-
assert_equal
|
115
|
+
output.stub :parse_table, :called do
|
116
|
+
assert_equal :called, output.table([])
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
@@ -124,10 +128,11 @@ describe CfScript::Output do
|
|
124
128
|
|
125
129
|
describe "section_attributes" do
|
126
130
|
it "calls parse_section_attributes" do
|
127
|
-
assert output.respond_to?(:section_attributes)
|
131
|
+
assert output.respond_to?(:section_attributes),
|
132
|
+
"Expected Output to respond to section_attributes"
|
128
133
|
|
129
|
-
output.stub :parse_section_attributes,
|
130
|
-
assert_equal
|
134
|
+
output.stub :parse_section_attributes, :called do
|
135
|
+
assert_equal :called, output.section_attributes('header')
|
131
136
|
end
|
132
137
|
end
|
133
138
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CfScript::Scope::App::Env do
|
4
|
+
include MockExecution
|
5
|
+
|
6
|
+
let(:target) { CfScript::Target.new('API', 'ORG', 'staging') }
|
7
|
+
|
8
|
+
def create_app(name)
|
9
|
+
app = nil
|
10
|
+
fake_cf { app = CfScript::Scope::App.new(:api, target) }
|
11
|
+
app
|
12
|
+
end
|
13
|
+
|
14
|
+
it "defines an env method that calls Command.env with the app name" do
|
15
|
+
app = create_app(:api)
|
16
|
+
|
17
|
+
arg_catcher = lambda do |command, *args, &block|
|
18
|
+
assert_equal :env, command
|
19
|
+
assert_equal [:api], args
|
20
|
+
|
21
|
+
return :called
|
22
|
+
end
|
23
|
+
|
24
|
+
CfScript::Command.stub :run, arg_catcher do
|
25
|
+
assert_equal :called, app.env
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "defines a set_env method that calls Command.set_env with the app name" do
|
30
|
+
app = create_app(:api)
|
31
|
+
|
32
|
+
arg_catcher = lambda do |command, *args, &block|
|
33
|
+
assert_equal :set_env, command
|
34
|
+
assert_equal [:api, 'name', 'value'], args
|
35
|
+
|
36
|
+
return :called
|
37
|
+
end
|
38
|
+
|
39
|
+
CfScript::Command.stub :run, arg_catcher do
|
40
|
+
assert_equal :called, app.set_env('name', 'value')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "defines an unset_env method that calls Command.unset_env with the app name" do
|
45
|
+
app = create_app(:api)
|
46
|
+
|
47
|
+
arg_catcher = lambda do |command, *args, &block|
|
48
|
+
assert_equal :unset_env, command
|
49
|
+
assert_equal [:api, 'name'], args
|
50
|
+
|
51
|
+
return :called
|
52
|
+
end
|
53
|
+
|
54
|
+
CfScript::Command.stub :run, arg_catcher do
|
55
|
+
assert_equal :called, app.unset_env('name')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CfScript::Scope::App::Routes do
|
4
|
+
include MockExecution
|
5
|
+
|
6
|
+
let(:target) { CfScript::Target.new('API', 'ORG', 'staging') }
|
7
|
+
|
8
|
+
def create_app(name)
|
9
|
+
app = nil
|
10
|
+
fake_cf { app = CfScript::Scope::App.new(:api, target) }
|
11
|
+
app
|
12
|
+
end
|
13
|
+
|
14
|
+
it "defines a has_route? method" do
|
15
|
+
app = create_app(:api)
|
16
|
+
|
17
|
+
app.stub :urls, ['api.example.com'] do
|
18
|
+
assert_equal false, app.has_route?('www.example.com')
|
19
|
+
assert_equal true, app.has_route?('api.example.com')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "defines a map_route method that calls Command.map_route with the app name" do
|
24
|
+
app = create_app(:api)
|
25
|
+
|
26
|
+
arg_catcher = lambda do |command, *args, &block|
|
27
|
+
assert_equal :map_route, command
|
28
|
+
assert_equal [:api, 'domain', nil], args
|
29
|
+
|
30
|
+
return :called
|
31
|
+
end
|
32
|
+
|
33
|
+
app.stub :cf_self, true do
|
34
|
+
CfScript::Command.stub :run, arg_catcher do
|
35
|
+
assert_equal :called, app.map_route('domain')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it "defines an unmap_route method that calls Command.unmap_route with the app name" do
|
41
|
+
app = create_app(:api)
|
42
|
+
|
43
|
+
arg_catcher = lambda do |command, *args, &block|
|
44
|
+
assert_equal :unmap_route, command
|
45
|
+
assert_equal [:api, 'domain', nil], args
|
46
|
+
|
47
|
+
return :called
|
48
|
+
end
|
49
|
+
|
50
|
+
app.stub :cf_self, true do
|
51
|
+
CfScript::Command.stub :run, arg_catcher do
|
52
|
+
assert_equal :called, app.unmap_route('domain')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -43,6 +43,21 @@ describe CfScript::Scope::App::State do
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
it "defines a restart method that calls Command.restart with the app name" do
|
47
|
+
app = create_app(:api)
|
48
|
+
|
49
|
+
arg_catcher = lambda do |command, *args, &block|
|
50
|
+
assert_equal :restart, command
|
51
|
+
assert_equal [:api], args
|
52
|
+
|
53
|
+
return :called
|
54
|
+
end
|
55
|
+
|
56
|
+
CfScript::Command.stub :run, arg_catcher do
|
57
|
+
assert_equal :called, app.restart
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
46
61
|
it "defines a push method that calls Command.push with the app name and options" do
|
47
62
|
app = create_app(:api)
|
48
63
|
|
@@ -58,4 +73,19 @@ describe CfScript::Scope::App::State do
|
|
58
73
|
assert_equal :called, app.push({ memory: '128MB' })
|
59
74
|
end
|
60
75
|
end
|
76
|
+
|
77
|
+
it "defines a restage method that calls Command.restage with the app name" do
|
78
|
+
app = create_app(:api)
|
79
|
+
|
80
|
+
arg_catcher = lambda do |command, *args, &block|
|
81
|
+
assert_equal :restage, command
|
82
|
+
assert_equal [:api], args
|
83
|
+
|
84
|
+
return :called
|
85
|
+
end
|
86
|
+
|
87
|
+
CfScript::Command.stub :run, arg_catcher do
|
88
|
+
assert_equal :called, app.restage
|
89
|
+
end
|
90
|
+
end
|
61
91
|
end
|
@@ -21,14 +21,15 @@ describe CfScript::Scope::Script do
|
|
21
21
|
script = CfScript::Scope::Script.new
|
22
22
|
end
|
23
23
|
|
24
|
-
assert script.respond_to?(:run)
|
24
|
+
assert script.respond_to?(:run), "Expected Scope::Script to respond to run"
|
25
25
|
|
26
26
|
arg_catcher = lambda do |scope, args, &block|
|
27
27
|
assert_same script, scope
|
28
|
+
return :called
|
28
29
|
end
|
29
30
|
|
30
31
|
script.stub :exec_in, arg_catcher do
|
31
|
-
|
32
|
+
assert_equal :called, script.run { nil }
|
32
33
|
end
|
33
34
|
end
|
34
35
|
|