roku_builder 3.12.8 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -2
- data/CHANGELOG +9 -0
- data/Gemfile.lock +17 -11
- data/bin/roku +4 -8
- data/lib/roku_builder.rb +16 -24
- data/lib/roku_builder/config.rb +213 -0
- data/lib/roku_builder/config_parser.rb +304 -267
- data/lib/roku_builder/config_validator.rb +149 -126
- data/lib/roku_builder/controller.rb +34 -184
- data/lib/roku_builder/controller_commands.rb +85 -79
- data/lib/roku_builder/error_handler.rb +0 -11
- data/lib/roku_builder/errors.rb +12 -0
- data/lib/roku_builder/inspector.rb +6 -4
- data/lib/roku_builder/keyer.rb +1 -1
- data/lib/roku_builder/loader.rb +1 -1
- data/lib/roku_builder/logger.rb +32 -0
- data/lib/roku_builder/manifest_manager.rb +2 -2
- data/lib/roku_builder/monitor.rb +1 -1
- data/lib/roku_builder/options.rb +113 -0
- data/lib/roku_builder/stager.rb +2 -2
- data/lib/roku_builder/tester.rb +57 -11
- data/lib/roku_builder/util.rb +3 -4
- data/lib/roku_builder/version.rb +1 -1
- data/roku_builder.gemspec +2 -1
- data/test/roku_builder/test_config.rb +168 -0
- data/test/roku_builder/test_config_parser.rb +347 -394
- data/test/roku_builder/test_config_validator.rb +193 -190
- data/test/roku_builder/test_controller.rb +59 -178
- data/test/roku_builder/test_controller_commands.rb +407 -394
- data/test/roku_builder/test_error_handler.rb +67 -69
- data/test/roku_builder/test_files/config_test/bad.json +2 -0
- data/test/roku_builder/test_files/config_test/child.json +11 -0
- data/test/roku_builder/test_files/config_test/config.json +29 -0
- data/test/roku_builder/test_files/config_test/non_json.json +1 -0
- data/test/roku_builder/test_files/config_test/parent.json +21 -0
- data/test/roku_builder/test_files/config_test/parent_projects.json +35 -0
- data/test/roku_builder/test_files/manifest_manager_test/manifest_template_2 +1 -1
- data/test/roku_builder/test_helper.rb +55 -45
- data/test/roku_builder/test_inspector.rb +278 -213
- data/test/roku_builder/test_keyer.rb +144 -147
- data/test/roku_builder/test_linker.rb +91 -95
- data/test/roku_builder/test_loader.rb +279 -289
- data/test/roku_builder/test_logger.rb +47 -0
- data/test/roku_builder/test_manifest_manager.rb +92 -94
- data/test/roku_builder/test_monitor.rb +101 -103
- data/test/roku_builder/test_navigator.rb +240 -245
- data/test/roku_builder/test_options.rb +156 -0
- data/test/roku_builder/test_packager.rb +108 -108
- data/test/roku_builder/test_profiler.rb +20 -19
- data/test/roku_builder/test_scripter.rb +83 -81
- data/test/roku_builder/test_stager.rb +299 -311
- data/test/roku_builder/test_tester.rb +112 -115
- data/test/roku_builder/test_util.rb +18 -17
- metadata +39 -6
- data/lib/roku_builder/config_manager.rb +0 -161
- data/test/roku_builder/test_config_manager.rb +0 -372
@@ -1,452 +1,465 @@
|
|
1
1
|
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
2
2
|
|
3
3
|
require_relative "test_helper.rb"
|
4
|
-
|
5
|
-
class ControllerCommandsTest < Minitest::Test
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
logger = Logger.new("/dev/null")
|
16
|
-
loader = Minitest::Mock.new
|
17
|
-
stager = Minitest::Mock.new
|
18
|
-
|
19
|
-
options = {sideload: true, config: "~/.roku_config.rb"}
|
20
|
-
config = good_config
|
21
|
-
code, configs = RokuBuilder::ConfigParser.parse_config(options: options, config: config, logger: logger)
|
22
|
-
# Test Success
|
23
|
-
loader.expect(:sideload, [RokuBuilder::SUCCESS, "build_version"], [configs[:sideload_config]])
|
24
|
-
stager.expect(:stage, true)
|
25
|
-
stager.expect(:unstage, true)
|
26
|
-
stager.expect(:method, :git)
|
27
|
-
|
28
|
-
RokuBuilder::Loader.stub(:new, loader) do
|
29
|
-
RokuBuilder::Stager.stub(:new, stager) do
|
30
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
31
|
-
end
|
4
|
+
module RokuBuilder
|
5
|
+
class ControllerCommandsTest < Minitest::Test
|
6
|
+
|
7
|
+
def test_controller_commands_validate
|
8
|
+
logger = Minitest::Mock.new
|
9
|
+
Logger.class_variable_set(:@@instance, logger)
|
10
|
+
logger.expect(:info, nil, ["Config validated"])
|
11
|
+
code = ControllerCommands.validate()
|
12
|
+
assert_equal SUCCESS, code
|
13
|
+
logger.verify
|
14
|
+
Logger.set_testing
|
32
15
|
end
|
33
|
-
|
16
|
+
def test_controller_commands_sideload
|
17
|
+
loader = Minitest::Mock.new
|
18
|
+
stager = Minitest::Mock.new
|
19
|
+
|
20
|
+
options = build_options({sideload: true, config: "~/.roku_config.rb", working: true})
|
21
|
+
config = Config.new(options: options)
|
22
|
+
config.instance_variable_set(:@config, good_config)
|
23
|
+
config.parse
|
24
|
+
# Test Success
|
25
|
+
loader.expect(:sideload, [SUCCESS, "build_version"], [config.parsed[:sideload_config]])
|
26
|
+
stager.expect(:stage, true)
|
27
|
+
stager.expect(:unstage, true)
|
28
|
+
stager.expect(:method, :git)
|
29
|
+
|
30
|
+
code = nil
|
31
|
+
Loader.stub(:new, loader) do
|
32
|
+
Stager.stub(:new, stager) do
|
33
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
34
|
+
end
|
35
|
+
end
|
36
|
+
assert_equal SUCCESS, code
|
34
37
|
|
35
|
-
|
36
|
-
|
38
|
+
stager.expect(:stage, true)
|
39
|
+
stager.expect(:unstage, true)
|
37
40
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
# Test Failure
|
42
|
+
loader.expect(:sideload, [FAILED_SIDELOAD, "build_version"], [config.parsed[:sideload_config]])
|
43
|
+
Loader.stub(:new, loader) do
|
44
|
+
Stager.stub(:new, stager) do
|
45
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
46
|
+
end
|
43
47
|
end
|
44
|
-
|
45
|
-
assert_equal RokuBuilder::FAILED_SIDELOAD, code
|
48
|
+
assert_equal FAILED_SIDELOAD, code
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
loader.verify
|
51
|
+
stager.verify
|
52
|
+
end
|
50
53
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
54
|
+
def test_controller_commands_package
|
55
|
+
keyer = Minitest::Mock.new
|
56
|
+
loader = Minitest::Mock.new
|
57
|
+
stager = Minitest::Mock.new
|
58
|
+
packager = Minitest::Mock.new
|
59
|
+
inspector = Minitest::Mock.new
|
60
|
+
|
61
|
+
options = build_options({package: true, inspect: true, out_folder: "/tmp", config: "~/.roku_config.json", set_stage: true})
|
62
|
+
config = Config.new(options: options)
|
63
|
+
config.instance_variable_set(:@config, good_config)
|
64
|
+
config.parse
|
65
|
+
info = {app_name: "app", dev_id: "id", creation_date: "date", dev_zip: ""}
|
66
|
+
|
67
|
+
loader.expect(:sideload, [SUCCESS, "build_version"], [config.parsed[:sideload_config]])
|
68
|
+
keyer.expect(:rekey, true, [config.parsed[:key]])
|
69
|
+
packager.expect(:package, true, [config.parsed[:package_config]])
|
70
|
+
inspector.expect(:inspect, info, [config.parsed[:inspect_config]])
|
71
|
+
stager.expect(:stage, true)
|
72
|
+
stager.expect(:unstage, true)
|
73
|
+
stager.expect(:method, :git)
|
74
|
+
|
75
|
+
code = nil
|
76
|
+
Keyer.stub(:new, keyer) do
|
77
|
+
Loader.stub(:new, loader) do
|
78
|
+
Packager.stub(:new, packager) do
|
79
|
+
Inspector.stub(:new, inspector) do
|
80
|
+
Stager.stub(:new, stager) do
|
81
|
+
::Logger.stub(:new, ::Logger.new("/dev/null")) do
|
82
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
83
|
+
end
|
80
84
|
end
|
81
85
|
end
|
82
86
|
end
|
83
87
|
end
|
84
88
|
end
|
85
|
-
|
86
|
-
assert_equal RokuBuilder::SUCCESS, code
|
89
|
+
assert_equal SUCCESS, code
|
87
90
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
91
|
+
keyer.verify
|
92
|
+
loader.verify
|
93
|
+
stager.verify
|
94
|
+
packager.verify
|
95
|
+
inspector.verify
|
96
|
+
end
|
94
97
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
98
|
+
def test_controller_commands_package_outfile
|
99
|
+
keyer = Minitest::Mock.new
|
100
|
+
loader = Minitest::Mock.new
|
101
|
+
stager = Minitest::Mock.new
|
102
|
+
packager = Minitest::Mock.new
|
103
|
+
inspector = Minitest::Mock.new
|
104
|
+
|
105
|
+
options = build_options({package: true, inspect: true, out: "/tmp/out.pkg", config: "~/.roku_config.json", set_stage: true})
|
106
|
+
config = Config.new(options: options)
|
107
|
+
config.instance_variable_set(:@config, good_config)
|
108
|
+
config.parse
|
109
|
+
info = {app_name: "app", dev_id: "id", creation_date: "date", dev_zip: ""}
|
110
|
+
|
111
|
+
loader.expect(:sideload, [SUCCESS, "build_version"], [config.parsed[:sideload_config]])
|
112
|
+
keyer.expect(:rekey, true, [config.parsed[:key]])
|
113
|
+
packager.expect(:package, true, [config.parsed[:package_config]])
|
114
|
+
inspector.expect(:inspect, info, [config.parsed[:inspect_config]])
|
115
|
+
stager.expect(:stage, true)
|
116
|
+
stager.expect(:unstage, true)
|
117
|
+
stager.expect(:method, :git)
|
118
|
+
|
119
|
+
code = nil
|
120
|
+
Keyer.stub(:new, keyer) do
|
121
|
+
Loader.stub(:new, loader) do
|
122
|
+
Packager.stub(:new, packager) do
|
123
|
+
Inspector.stub(:new, inspector) do
|
124
|
+
Stager.stub(:new, stager) do
|
125
|
+
::Logger.stub(:new, ::Logger.new("/dev/null")) do
|
126
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
127
|
+
end
|
124
128
|
end
|
125
129
|
end
|
126
130
|
end
|
127
131
|
end
|
128
132
|
end
|
129
|
-
|
130
|
-
assert_equal RokuBuilder::SUCCESS, code
|
133
|
+
assert_equal SUCCESS, code
|
131
134
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
keyer.verify
|
136
|
+
loader.verify
|
137
|
+
stager.verify
|
138
|
+
packager.verify
|
139
|
+
inspector.verify
|
140
|
+
end
|
138
141
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
142
|
+
def test_controller_commands_build
|
143
|
+
loader = Minitest::Mock.new
|
144
|
+
stager = Minitest::Mock.new
|
145
|
+
|
146
|
+
code = nil
|
147
|
+
options = build_options({build: true, out_folder: "/tmp", config: "~/.roku_config.json", working: true})
|
148
|
+
config = Config.new(options: options)
|
149
|
+
config.instance_variable_set(:@config, good_config)
|
150
|
+
config.parse
|
151
|
+
loader.expect(:build, "/tmp/build", [config.parsed[:build_config]])
|
152
|
+
stager.expect(:stage, true)
|
153
|
+
stager.expect(:unstage, true)
|
154
|
+
stager.expect(:method, :git)
|
155
|
+
|
156
|
+
Loader.stub(:new, loader) do
|
157
|
+
ManifestManager.stub(:build_version, "1") do
|
158
|
+
Stager.stub(:new, stager) do
|
159
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
160
|
+
end
|
157
161
|
end
|
158
162
|
end
|
163
|
+
assert_equal SUCCESS, code
|
164
|
+
loader.verify
|
165
|
+
stager.verify
|
159
166
|
end
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
RokuBuilder::ManifestManager.stub(:update_build, mock) do
|
180
|
-
RokuBuilder::Stager.stub(:new, stager) do
|
181
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
167
|
+
def test_controller_commands_update
|
168
|
+
mock = Minitest::Mock.new
|
169
|
+
stager = Minitest::Mock.new
|
170
|
+
|
171
|
+
code = nil
|
172
|
+
options = build_options({update: true, out_folder: "/tmp", config: "~/.roku_config.json", working: true})
|
173
|
+
config = Config.new(options: options)
|
174
|
+
config.instance_variable_set(:@config, good_config)
|
175
|
+
config.parse
|
176
|
+
mock.expect(:call, "1", [config.parsed[:manifest_config]])
|
177
|
+
mock.expect(:call, "2", [config.parsed[:manifest_config]])
|
178
|
+
stager.expect(:stage, true)
|
179
|
+
stager.expect(:unstage, true)
|
180
|
+
|
181
|
+
ManifestManager.stub(:build_version, mock) do
|
182
|
+
ManifestManager.stub(:update_build, mock) do
|
183
|
+
Stager.stub(:new, stager) do
|
184
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
185
|
+
end
|
182
186
|
end
|
183
187
|
end
|
188
|
+
mock.verify
|
189
|
+
stager.verify
|
190
|
+
assert_equal SUCCESS, code
|
184
191
|
end
|
185
|
-
mock.verify
|
186
|
-
stager.verify
|
187
|
-
assert_equal RokuBuilder::SUCCESS, code
|
188
|
-
end
|
189
192
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
193
|
+
def test_controller_commands_deeplink
|
194
|
+
mock = Minitest::Mock.new
|
195
|
+
|
196
|
+
code = nil
|
197
|
+
options = build_options({deeplink: true, deeplink_options: "a:b", config: "~/.roku_config.json"})
|
198
|
+
config = Config.new(options: options)
|
199
|
+
config.instance_variable_set(:@config, good_config)
|
200
|
+
config.parse
|
201
|
+
mock.expect(:launch, "true", [config.parsed[:deeplink_config]])
|
202
|
+
Linker.stub(:new, mock) do
|
203
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
204
|
+
end
|
205
|
+
mock.verify
|
206
|
+
assert_equal SUCCESS, code
|
201
207
|
end
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
RokuBuilder::ControllerCommands.stub(:sideload, sideload) do
|
220
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
208
|
+
def test_controller_commands_deeplink_sideload
|
209
|
+
mock = Minitest::Mock.new
|
210
|
+
|
211
|
+
ran_sideload = false
|
212
|
+
|
213
|
+
sideload = Proc.new {|a, b, c| ran_sideload = true}
|
214
|
+
|
215
|
+
code = nil
|
216
|
+
options = build_options({deeplink: true, set_stage: true, deeplink_options: "a:b", config: "~/.roku_config.json"})
|
217
|
+
config = Config.new(options: options)
|
218
|
+
config.instance_variable_set(:@config, good_config)
|
219
|
+
config.parse
|
220
|
+
mock.expect(:launch, "true", [config.parsed[:deeplink_config]])
|
221
|
+
Linker.stub(:new, mock) do
|
222
|
+
ControllerCommands.stub(:sideload, sideload) do
|
223
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
224
|
+
end
|
221
225
|
end
|
226
|
+
mock.verify
|
227
|
+
assert_equal SUCCESS, code
|
228
|
+
assert ran_sideload
|
222
229
|
end
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
RokuBuilder::Linker.stub(:new, mock) do
|
240
|
-
RokuBuilder::Stager.stub(:new, stager) do
|
241
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
230
|
+
def test_controller_commands_deeplink_fail
|
231
|
+
mock = Minitest::Mock.new
|
232
|
+
stager = Minitest::Mock.new
|
233
|
+
|
234
|
+
code = nil
|
235
|
+
options = build_options({deeplink: true, deeplink_options: "a:b", config: "~/.roku_config.json"})
|
236
|
+
config = Config.new(options: options)
|
237
|
+
config.instance_variable_set(:@config, good_config)
|
238
|
+
config.parse
|
239
|
+
mock.expect(:launch, false, [config.parsed[:deeplink_config]])
|
240
|
+
stager.expect(:stage, true)
|
241
|
+
stager.expect(:unstage, true)
|
242
|
+
Linker.stub(:new, mock) do
|
243
|
+
Stager.stub(:new, stager) do
|
244
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
245
|
+
end
|
242
246
|
end
|
247
|
+
mock.verify
|
248
|
+
assert_equal FAILED_DEEPLINKING, code
|
243
249
|
end
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
RokuBuilder::ManifestManager.stub(:build_version, "1") do
|
258
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
250
|
+
def test_controller_commands_delete
|
251
|
+
loader = Minitest::Mock.new
|
252
|
+
|
253
|
+
options = build_options({delete: true, config: "~/.roku_config.json"})
|
254
|
+
config = Config.new(options: options)
|
255
|
+
config.instance_variable_set(:@config, good_config)
|
256
|
+
config.parse
|
257
|
+
loader.expect(:unload, nil)
|
258
|
+
code = nil
|
259
|
+
Loader.stub(:new, loader) do
|
260
|
+
ManifestManager.stub(:build_version, "1") do
|
261
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
262
|
+
end
|
259
263
|
end
|
264
|
+
assert_equal SUCCESS, code
|
265
|
+
loader.verify
|
260
266
|
end
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
RokuBuilder::ManifestManager.stub(:build_version, "1") do
|
275
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
267
|
+
def test_controller_commands_monitor
|
268
|
+
monitor = Minitest::Mock.new
|
269
|
+
|
270
|
+
options = build_options({monitor: "main", config: "~/.roku_config.json"})
|
271
|
+
config = Config.new(options: options)
|
272
|
+
config.instance_variable_set(:@config, good_config)
|
273
|
+
config.parse
|
274
|
+
monitor.expect(:monitor, nil, [config.parsed[:monitor_config]])
|
275
|
+
code = nil
|
276
|
+
Monitor.stub(:new, monitor) do
|
277
|
+
ManifestManager.stub(:build_version, "1") do
|
278
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
279
|
+
end
|
276
280
|
end
|
281
|
+
assert_equal SUCCESS, code
|
282
|
+
monitor.verify
|
277
283
|
end
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
284
|
+
def test_controller_commands_navigate
|
285
|
+
navigator = Minitest::Mock.new
|
286
|
+
|
287
|
+
options = build_options({navigate: "up", config: "~/.roku_config.json"})
|
288
|
+
config = Config.new(options: options)
|
289
|
+
config.instance_variable_set(:@config, good_config)
|
290
|
+
config.parse
|
291
|
+
navigator.expect(:nav, true, [config.parsed[:navigate_config]])
|
292
|
+
code = nil
|
293
|
+
Navigator.stub(:new, navigator) do
|
294
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
295
|
+
end
|
296
|
+
assert_equal SUCCESS, code
|
297
|
+
navigator.verify
|
292
298
|
end
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
299
|
+
def test_controller_commands_navigate_fail
|
300
|
+
navigator = Minitest::Mock.new
|
301
|
+
|
302
|
+
options = build_options({navigate: "up", config: ":execute_commands,/.roku_config.json"})
|
303
|
+
config = Config.new(options: options)
|
304
|
+
config.instance_variable_set(:@config, good_config)
|
305
|
+
config.parse
|
306
|
+
navigator.expect(:nav, nil, [config.parsed[:navigate_config]])
|
307
|
+
code = nil
|
308
|
+
Navigator.stub(:new, navigator) do
|
309
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
310
|
+
end
|
311
|
+
assert_equal FAILED_NAVIGATING, code
|
312
|
+
navigator.verify
|
307
313
|
end
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
314
|
+
def test_controller_commands_screen
|
315
|
+
navigator = Minitest::Mock.new
|
316
|
+
|
317
|
+
options = build_options({screen: "secret", config: "~/.roku_config.json"})
|
318
|
+
config = Config.new(options: options)
|
319
|
+
config.instance_variable_set(:@config, good_config)
|
320
|
+
config.parse
|
321
|
+
navigator.expect(:screen, true, [config.parsed[:screen_config]])
|
322
|
+
code = nil
|
323
|
+
Navigator.stub(:new, navigator) do
|
324
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
325
|
+
end
|
326
|
+
assert_equal SUCCESS, code
|
327
|
+
navigator.verify
|
322
328
|
end
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
329
|
+
def test_controller_commands_screens
|
330
|
+
navigator = Minitest::Mock.new
|
331
|
+
|
332
|
+
options = build_options({screens: true, config: "~/.roku_config.json"})
|
333
|
+
config = Config.new(options: options)
|
334
|
+
config.instance_variable_set(:@config, good_config)
|
335
|
+
config.parse
|
336
|
+
navigator.expect(:screens, true)
|
337
|
+
code = nil
|
338
|
+
Navigator.stub(:new, navigator) do
|
339
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
340
|
+
end
|
341
|
+
assert_equal SUCCESS, code
|
342
|
+
navigator.verify
|
337
343
|
end
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
344
|
+
def test_controller_commands_text
|
345
|
+
navigator = Minitest::Mock.new
|
346
|
+
|
347
|
+
options = build_options({text: "text string", config: "~/.roku_config.json"})
|
348
|
+
config = Config.new(options: options)
|
349
|
+
config.instance_variable_set(:@config, good_config)
|
350
|
+
config.parse
|
351
|
+
navigator.expect(:type, true, [config.parsed[:text_config]])
|
352
|
+
code = nil
|
353
|
+
Navigator.stub(:new, navigator) do
|
354
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
355
|
+
end
|
356
|
+
assert_equal SUCCESS, code
|
357
|
+
navigator.verify
|
352
358
|
end
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
359
|
+
def test_controller_commands_test
|
360
|
+
tester = Minitest::Mock.new
|
361
|
+
stager = Minitest::Mock.new
|
362
|
+
|
363
|
+
options = build_options({test: true, config: "~/.roku_config.json", working: true})
|
364
|
+
config = Config.new(options: options)
|
365
|
+
config.instance_variable_set(:@config, good_config)
|
366
|
+
config.parse
|
367
|
+
tester.expect(:run_tests, true, [config.parsed[:test_config]])
|
368
|
+
stager.expect(:stage, true)
|
369
|
+
stager.expect(:unstage, true)
|
370
|
+
code = nil
|
371
|
+
|
372
|
+
Stager.stub(:new, stager) do
|
373
|
+
Tester.stub(:new, tester) do
|
374
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
375
|
+
end
|
376
|
+
end
|
377
|
+
assert_equal SUCCESS, code
|
378
|
+
tester.verify
|
379
|
+
stager.verify
|
367
380
|
end
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
381
|
+
def test_controller_commands_screencapture
|
382
|
+
inspector = Minitest::Mock.new
|
383
|
+
|
384
|
+
options = build_options({screencapture: true, out: "/tmp/capture.jpg", config: "~/.roku_config.json"})
|
385
|
+
config = Config.new(options: options)
|
386
|
+
config.instance_variable_set(:@config, good_config)
|
387
|
+
config.parse
|
388
|
+
inspector.expect(:screencapture, true, [config.parsed[:screencapture_config]])
|
389
|
+
code = nil
|
390
|
+
Inspector.stub(:new, inspector) do
|
391
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
392
|
+
end
|
393
|
+
assert_equal SUCCESS, code
|
394
|
+
inspector.verify
|
382
395
|
end
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
396
|
+
def test_controller_commands_screencapture_fail
|
397
|
+
inspector = Minitest::Mock.new
|
398
|
+
|
399
|
+
options = build_options({screencapture: true, out: "/tmp", config: "~/.roku_config.json"})
|
400
|
+
config = Config.new(options: options)
|
401
|
+
config.instance_variable_set(:@config, good_config)
|
402
|
+
config.parse
|
403
|
+
inspector.expect(:screencapture, false, [config.parsed[:screencapture_config]])
|
404
|
+
code = nil
|
405
|
+
Inspector.stub(:new, inspector) do
|
406
|
+
code = Controller.send(:execute_commands, {options: options, config: config })
|
407
|
+
end
|
408
|
+
assert_equal FAILED_SCREENCAPTURE, code
|
409
|
+
inspector.verify
|
397
410
|
end
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
code = RokuBuilder::Controller.send(:execute_commands, {options: options, configs: configs, logger: logger})
|
411
|
+
def test_controller_commands_print
|
412
|
+
stager = Minitest::Mock.new
|
413
|
+
|
414
|
+
options = build_options({print: 'title', config: "~/.roku_config.json", working: true})
|
415
|
+
configs = {stage_config: {}}
|
416
|
+
config = Config.new(options: options)
|
417
|
+
config.instance_variable_set(:@parsed, configs)
|
418
|
+
code = nil
|
419
|
+
scripter_config = {attribute: :title, configs: configs}
|
420
|
+
print_check = lambda {|print_config| SUCCESS if print_config == scripter_config }
|
421
|
+
stager.expect(:stage, true)
|
422
|
+
stager.expect(:unstage, true)
|
423
|
+
|
424
|
+
Stager.stub(:new, stager) do
|
425
|
+
Scripter.stub(:print, print_check) do
|
426
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
427
|
+
end
|
416
428
|
end
|
429
|
+
assert_equal SUCCESS, code
|
430
|
+
stager.verify
|
417
431
|
end
|
418
|
-
|
419
|
-
|
420
|
-
end
|
421
|
-
def test_controller_commands_dostage
|
422
|
-
logger = Logger.new("/dev/null")
|
423
|
-
stager = Minitest::Mock.new
|
432
|
+
def test_controller_commands_dostage
|
433
|
+
stager = Minitest::Mock.new
|
424
434
|
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
435
|
+
options = build_options({dostage: true, config: "~/.roku_config.json"})
|
436
|
+
config = Config.new(options: options)
|
437
|
+
config.instance_variable_set(:@parsed, {stage_config: {}})
|
438
|
+
code = nil
|
439
|
+
stager.expect(:stage, true)
|
429
440
|
|
430
|
-
|
431
|
-
|
441
|
+
Stager.stub(:new, stager) do
|
442
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
443
|
+
end
|
444
|
+
assert_equal true, code
|
445
|
+
stager.verify
|
432
446
|
end
|
433
|
-
assert_equal true, code
|
434
|
-
stager.verify
|
435
|
-
end
|
436
447
|
|
437
|
-
|
438
|
-
|
439
|
-
stager = Minitest::Mock.new
|
448
|
+
def test_controller_commands_dounstage
|
449
|
+
stager = Minitest::Mock.new
|
440
450
|
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
451
|
+
options = build_options({dounstage: true, config: "~/.roku_config.json"})
|
452
|
+
configs = {stage_config: {}}
|
453
|
+
config = Config.new(options: options)
|
454
|
+
config.instance_variable_set(:@parsed, configs)
|
455
|
+
code = nil
|
456
|
+
stager.expect(:unstage, true)
|
445
457
|
|
446
|
-
|
447
|
-
|
458
|
+
Stager.stub(:new, stager) do
|
459
|
+
code = Controller.send(:execute_commands, {options: options, config: config})
|
460
|
+
end
|
461
|
+
assert_equal true, code
|
462
|
+
stager.verify
|
448
463
|
end
|
449
|
-
assert_equal true, code
|
450
|
-
stager.verify
|
451
464
|
end
|
452
465
|
end
|