roku_builder 3.12.8 → 3.13.0
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.
- 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
|
@@ -2,195 +2,198 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "test_helper.rb"
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
5
|
+
module RokuBuilder
|
|
6
|
+
class ConfigValidatorTest < Minitest::Test
|
|
7
|
+
|
|
8
|
+
def test_config_manager_validate_devices
|
|
9
|
+
config = good_config
|
|
10
|
+
config[:devices] = nil
|
|
11
|
+
validator = ConfigValidator.new(config: config)
|
|
12
|
+
assert validator.is_fatal?
|
|
13
|
+
assert_equal [1], validator.instance_variable_get(:@codes)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_config_manager_validate_devices_default
|
|
17
|
+
config = good_config
|
|
18
|
+
config[:devices][:default] = nil
|
|
19
|
+
validator = ConfigValidator.new(config: config)
|
|
20
|
+
assert_equal [2], validator.instance_variable_get(:@codes)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_config_manager_validate_devices_default_is_symbol
|
|
24
|
+
config = good_config
|
|
25
|
+
config[:devices][:default] = "bad"
|
|
26
|
+
validator = ConfigValidator.new(config: config)
|
|
27
|
+
assert_equal [3], validator.instance_variable_get(:@codes)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_config_manager_validate_device_ip
|
|
31
|
+
config = good_config
|
|
32
|
+
config[:devices][:roku][:ip] = nil
|
|
33
|
+
validator = ConfigValidator.new(config: config)
|
|
34
|
+
assert_equal [7], validator.instance_variable_get(:@codes)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_config_manager_validate_device_ip_empty
|
|
38
|
+
config = good_config
|
|
39
|
+
config[:devices][:roku][:ip] = ""
|
|
40
|
+
validator = ConfigValidator.new(config: config)
|
|
41
|
+
assert_equal [7], validator.instance_variable_get(:@codes)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_config_manager_validate_device_ip_default_value
|
|
45
|
+
config = good_config
|
|
46
|
+
config[:devices][:roku][:ip] = "xxx.xxx.xxx.xxx"
|
|
47
|
+
validator = ConfigValidator.new(config: config)
|
|
48
|
+
assert_equal [7], validator.instance_variable_get(:@codes)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_config_manager_validate_device_user
|
|
52
|
+
config = good_config
|
|
53
|
+
config[:devices][:roku][:user] = nil
|
|
54
|
+
validator = ConfigValidator.new(config: config)
|
|
55
|
+
assert_equal [8], validator.instance_variable_get(:@codes)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def test_config_manager_validate_device_user_empty
|
|
59
|
+
config = good_config
|
|
60
|
+
config[:devices][:roku][:user] = ""
|
|
61
|
+
validator = ConfigValidator.new(config: config)
|
|
62
|
+
assert_equal [8], validator.instance_variable_get(:@codes)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def test_config_manager_validate_device_user_default_value
|
|
66
|
+
config = good_config
|
|
67
|
+
config[:devices][:roku][:user] = "<username>"
|
|
68
|
+
validator = ConfigValidator.new(config: config)
|
|
69
|
+
assert_equal [8], validator.instance_variable_get(:@codes)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def test_config_manager_validate_device_password
|
|
73
|
+
config = good_config
|
|
74
|
+
config[:devices][:roku][:password] = nil
|
|
75
|
+
validator = ConfigValidator.new(config: config)
|
|
76
|
+
assert_equal [9], validator.instance_variable_get(:@codes)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_config_manager_validate_device_password_empty
|
|
80
|
+
config = good_config
|
|
81
|
+
config[:devices][:roku][:password] = ""
|
|
82
|
+
validator = ConfigValidator.new(config: config)
|
|
83
|
+
assert_equal [9], validator.instance_variable_get(:@codes)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def test_config_manager_validate_device_password_default_value
|
|
87
|
+
config = good_config
|
|
88
|
+
config[:devices][:roku][:password] = "<password>"
|
|
89
|
+
validator = ConfigValidator.new(config: config)
|
|
90
|
+
assert_equal [9], validator.instance_variable_get(:@codes)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def test_config_manager_validate_projects
|
|
94
|
+
config = good_config
|
|
95
|
+
config[:projects] = nil
|
|
96
|
+
validator = ConfigValidator.new(config: config)
|
|
97
|
+
assert validator.is_valid?
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def test_config_manager_validate_projects_default
|
|
101
|
+
config = good_config
|
|
102
|
+
config[:projects][:default] = nil
|
|
103
|
+
validator = ConfigValidator.new(config: config)
|
|
104
|
+
assert_equal [5], validator.instance_variable_get(:@codes)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def test_config_manager_validate_projects_default_default_value
|
|
108
|
+
config = good_config
|
|
109
|
+
config[:projects][:default] = "<project id>".to_sym
|
|
110
|
+
validator = ConfigValidator.new(config: config)
|
|
111
|
+
assert_equal [5], validator.instance_variable_get(:@codes)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def test_config_manager_validate_projects_default_is_symbol
|
|
115
|
+
config = good_config
|
|
116
|
+
config[:projects][:default] = "project_id"
|
|
117
|
+
validator = ConfigValidator.new(config: config)
|
|
118
|
+
assert_equal [6], validator.instance_variable_get(:@codes)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def test_config_manager_validate_project_app_name
|
|
122
|
+
config = good_config
|
|
123
|
+
config[:projects][:project1][:app_name] = nil
|
|
124
|
+
validator = ConfigValidator.new(config: config)
|
|
125
|
+
assert_equal [10], validator.instance_variable_get(:@codes)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def test_config_manager_validate_project_directory
|
|
129
|
+
config = good_config
|
|
130
|
+
config[:projects][:project1][:directory] = nil
|
|
131
|
+
validator = ConfigValidator.new(config: config)
|
|
132
|
+
assert_equal [11], validator.instance_variable_get(:@codes)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def test_config_manager_validate_project_folders
|
|
136
|
+
config = good_config
|
|
137
|
+
config[:projects][:project1][:folders] = nil
|
|
138
|
+
validator = ConfigValidator.new(config: config)
|
|
139
|
+
assert_equal [12], validator.instance_variable_get(:@codes)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def test_config_manager_validate_project_folders_is_array
|
|
143
|
+
config = good_config
|
|
144
|
+
config[:projects][:project1][:folders] = "Folders"
|
|
145
|
+
validator = ConfigValidator.new(config: config)
|
|
146
|
+
assert_equal [13], validator.instance_variable_get(:@codes)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def test_config_manager_validate_project_files
|
|
150
|
+
config = good_config
|
|
151
|
+
config[:projects][:project1][:files] = nil
|
|
152
|
+
validator = ConfigValidator.new(config: config)
|
|
153
|
+
assert_equal [14], validator.instance_variable_get(:@codes)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def test_config_manager_validate_project_filess_is_array
|
|
157
|
+
config = good_config
|
|
158
|
+
config[:projects][:project1][:files] = "Files"
|
|
159
|
+
validator = ConfigValidator.new(config: config)
|
|
160
|
+
assert_equal [15], validator.instance_variable_get(:@codes)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def test_config_manager_validate_project_key
|
|
164
|
+
config = good_config
|
|
165
|
+
config[:projects][:project2][:stages][:production][:key] = "b"
|
|
166
|
+
validator = ConfigValidator.new(config: config)
|
|
167
|
+
assert_equal [22], validator.instance_variable_get(:@codes)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
def test_config_manager_validate_keys_pkg
|
|
171
|
+
config = good_config
|
|
172
|
+
config[:keys][:a][:keyed_pkg] = nil
|
|
173
|
+
validator = ConfigValidator.new(config: config)
|
|
174
|
+
assert_equal [19], validator.instance_variable_get(:@codes)
|
|
175
|
+
config = good_config
|
|
176
|
+
config[:keys][:a][:keyed_pkg] = "<path/to/signed/package>"
|
|
177
|
+
validator = ConfigValidator.new(config: config)
|
|
178
|
+
assert_equal [19], validator.instance_variable_get(:@codes)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def test_config_manager_validate_keys_password
|
|
182
|
+
config = good_config
|
|
183
|
+
config[:keys][:a][:password] = nil
|
|
184
|
+
validator = ConfigValidator.new(config: config)
|
|
185
|
+
assert_equal [20], validator.instance_variable_get(:@codes)
|
|
186
|
+
config = good_config
|
|
187
|
+
config[:keys][:a][:password] = "<password>"
|
|
188
|
+
validator = ConfigValidator.new(config: config)
|
|
189
|
+
assert_equal [20], validator.instance_variable_get(:@codes)
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def test_config_manager_validate_input_mappings
|
|
193
|
+
config = good_config
|
|
194
|
+
config[:input_mapping]["a"] = ["home"]
|
|
195
|
+
validator = ConfigValidator.new(config: config)
|
|
196
|
+
assert_equal [21], validator.instance_variable_get(:@codes)
|
|
197
|
+
end
|
|
195
198
|
end
|
|
196
199
|
end
|
|
@@ -1,188 +1,69 @@
|
|
|
1
1
|
# ********** Copyright Viacom, Inc. Apache 2.0 **********
|
|
2
2
|
|
|
3
3
|
require_relative "test_helper.rb"
|
|
4
|
-
|
|
5
|
-
class ControllerTest < Minitest::Test
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
sideload: true,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
assert_equal RokuBuilder::VALID, RokuBuilder::Controller.send(:validate_options, {options: options})
|
|
49
|
-
options = {
|
|
50
|
-
package: true,
|
|
51
|
-
in: "",
|
|
52
|
-
set_stage: true
|
|
53
|
-
}
|
|
54
|
-
assert_equal RokuBuilder::EXTRA_SOURCES, RokuBuilder::Controller.send(:validate_options, {options: options})
|
|
55
|
-
end
|
|
56
|
-
def test_controller_configure
|
|
57
|
-
logger = Logger.new("/dev/null")
|
|
58
|
-
target_config = File.join(File.dirname(__FILE__), "test_files", "controller_test", "configure_test.json")
|
|
59
|
-
File.delete(target_config) if File.exist?(target_config)
|
|
60
|
-
assert !File.exist?(target_config)
|
|
61
|
-
|
|
62
|
-
options = {
|
|
63
|
-
configure: true,
|
|
64
|
-
config: target_config,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
code = RokuBuilder::Controller.send(:configure, {options: options, logger: logger})
|
|
68
|
-
|
|
69
|
-
assert File.exist?(target_config)
|
|
70
|
-
|
|
71
|
-
options = {
|
|
72
|
-
configure: true,
|
|
73
|
-
config: target_config,
|
|
74
|
-
edit_params: "ip:111.222.333.444"
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
code = RokuBuilder::Controller.send(:configure, {options: options, logger: logger})
|
|
78
|
-
|
|
79
|
-
assert File.exist?(target_config)
|
|
80
|
-
config = RokuBuilder::ConfigManager.get_config(config: target_config, logger: logger)
|
|
81
|
-
assert_equal "111.222.333.444", config[:devices][config[:devices][:default]][:ip]
|
|
82
|
-
|
|
83
|
-
options = {
|
|
84
|
-
configure: true,
|
|
85
|
-
config: target_config
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
code = RokuBuilder::Controller.send(:configure, {options: options, logger: logger})
|
|
89
|
-
|
|
90
|
-
assert_equal RokuBuilder::CONFIG_OVERWRITE, code
|
|
91
|
-
|
|
92
|
-
File.delete(target_config) if File.exist?(target_config)
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def test_controller_check_devices
|
|
96
|
-
logger = Logger.new("/dev/null")
|
|
97
|
-
ping = Minitest::Mock.new
|
|
98
|
-
options = {sideload: true, device_given: false}
|
|
99
|
-
config = {}
|
|
100
|
-
config[:devices] = {
|
|
101
|
-
a: {ip: "2.2.2.2"},
|
|
102
|
-
b: {ip: "3.3.3.3"}
|
|
103
|
-
}
|
|
104
|
-
configs = {
|
|
105
|
-
device_config: {ip: "1.1.1.1"}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
Net::Ping::External.stub(:new, ping) do
|
|
109
|
-
|
|
110
|
-
ping.expect(:ping?, true, [configs[:device_config][:ip], 1, 0.2, 1])
|
|
111
|
-
code, ret = RokuBuilder::Controller.send(:check_devices, {options: options, config: config, configs: configs, logger: logger})
|
|
112
|
-
assert_equal RokuBuilder::GOOD_DEVICE, code
|
|
113
|
-
|
|
114
|
-
ping.expect(:ping?, false, [configs[:device_config][:ip], 1, 0.2, 1])
|
|
115
|
-
ping.expect(:ping?, false, [config[:devices][:a][:ip], 1, 0.2, 1])
|
|
116
|
-
ping.expect(:ping?, false, [config[:devices][:b][:ip], 1, 0.2, 1])
|
|
117
|
-
code, ret = RokuBuilder::Controller.send(:check_devices, {options: options, config: config, configs: configs, logger: logger})
|
|
118
|
-
assert_equal RokuBuilder::NO_DEVICES, code
|
|
119
|
-
|
|
120
|
-
ping.expect(:ping?, false, [configs[:device_config][:ip], 1, 0.2, 1])
|
|
121
|
-
ping.expect(:ping?, true, [config[:devices][:a][:ip], 1, 0.2, 1])
|
|
122
|
-
code, ret = RokuBuilder::Controller.send(:check_devices, {options: options, config: config, configs: configs, logger: logger})
|
|
123
|
-
assert_equal RokuBuilder::CHANGED_DEVICE, code
|
|
124
|
-
assert_equal config[:devices][:a][:ip], ret[:device_config][:ip]
|
|
125
|
-
|
|
126
|
-
options[:device_given] = true
|
|
127
|
-
ping.expect(:ping?, false, [configs[:device_config][:ip], 1, 0.2, 1])
|
|
128
|
-
code, ret = RokuBuilder::Controller.send(:check_devices, {options: options, config: config, configs: configs, logger: logger})
|
|
129
|
-
assert_equal RokuBuilder::BAD_DEVICE, code
|
|
130
|
-
|
|
131
|
-
options = {build: true, device_given: false}
|
|
132
|
-
code, ret = RokuBuilder::Controller.send(:check_devices, {options: options, config: config, configs: configs, logger: logger})
|
|
133
|
-
assert_equal RokuBuilder::GOOD_DEVICE, code
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
def test_controller_run_debug
|
|
138
|
-
tests = [
|
|
139
|
-
{options: {debug: true}, level: Logger::DEBUG},
|
|
140
|
-
{options: {verbose: true}, level: Logger::INFO},
|
|
141
|
-
{options: {}, level: Logger::WARN}
|
|
142
|
-
]
|
|
143
|
-
tests.each do |test|
|
|
144
|
-
logger = Minitest::Mock.new
|
|
145
|
-
logger.expect(:level=, nil, [test[:level]])
|
|
146
|
-
RokuBuilder::Controller.stub(:validate_options, nil) do
|
|
147
|
-
RokuBuilder::ErrorHandler.stub(:handle_options_codes, nil) do
|
|
148
|
-
RokuBuilder::Controller.stub(:configure, nil) do
|
|
149
|
-
RokuBuilder::ErrorHandler.stub(:handle_configure_codes, nil) do
|
|
150
|
-
RokuBuilder::ConfigManager.stub(:load_config, nil) do
|
|
151
|
-
RokuBuilder::ErrorHandler.stub(:handle_load_codes, nil) do
|
|
152
|
-
RokuBuilder::Controller.stub(:validate_configs, nil) do
|
|
153
|
-
RokuBuilder::ErrorHandler.stub(:handle_configs_codes, nil) do
|
|
154
|
-
RokuBuilder::Controller.stub(:check_devices, nil) do
|
|
155
|
-
RokuBuilder::ErrorHandler.stub(:handle_device_codes, nil) do
|
|
156
|
-
RokuBuilder::Controller.stub(:execute_commands, nil) do
|
|
157
|
-
RokuBuilder::ErrorHandler.stub(:handle_command_codes, nil) do
|
|
158
|
-
RokuBuilder::Controller.run(options: test[:options], logger: logger)
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
end
|
|
4
|
+
module RokuBuilder
|
|
5
|
+
class ControllerTest < Minitest::Test
|
|
6
|
+
def test_controller_check_devices
|
|
7
|
+
ping = Minitest::Mock.new
|
|
8
|
+
options = build_options({sideload: true, device_given: false, working: true})
|
|
9
|
+
raw = {
|
|
10
|
+
devices: {
|
|
11
|
+
a: {ip: "2.2.2.2"},
|
|
12
|
+
b: {ip: "3.3.3.3"}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
parsed = {
|
|
16
|
+
device_config: {ip: "1.1.1.1"}
|
|
17
|
+
}
|
|
18
|
+
config = Config.new(options: options)
|
|
19
|
+
config.instance_variable_set(:@config, raw)
|
|
20
|
+
config.instance_variable_set(:@parsed, parsed)
|
|
21
|
+
|
|
22
|
+
Net::Ping::External.stub(:new, ping) do
|
|
23
|
+
|
|
24
|
+
ping.expect(:ping?, true, [parsed[:device_config][:ip], 1, 0.2, 1])
|
|
25
|
+
code, ret = Controller.send(:check_devices, {options: options, config: config})
|
|
26
|
+
assert_equal GOOD_DEVICE, code
|
|
27
|
+
|
|
28
|
+
ping.expect(:ping?, false, [parsed[:device_config][:ip], 1, 0.2, 1])
|
|
29
|
+
ping.expect(:ping?, false, [raw[:devices][:a][:ip], 1, 0.2, 1])
|
|
30
|
+
ping.expect(:ping?, false, [raw[:devices][:b][:ip], 1, 0.2, 1])
|
|
31
|
+
code = Controller.send(:check_devices, {options: options, config: config})
|
|
32
|
+
assert_equal NO_DEVICES, code
|
|
33
|
+
|
|
34
|
+
ping.expect(:ping?, false, [parsed[:device_config][:ip], 1, 0.2, 1])
|
|
35
|
+
ping.expect(:ping?, true, [raw[:devices][:a][:ip], 1, 0.2, 1])
|
|
36
|
+
code = Controller.send(:check_devices, {options: options, config: config})
|
|
37
|
+
assert_equal CHANGED_DEVICE, code
|
|
38
|
+
assert_equal raw[:devices][:a][:ip], config.parsed[:device_config][:ip]
|
|
39
|
+
|
|
40
|
+
options[:device_given] = true
|
|
41
|
+
ping.expect(:ping?, false, [parsed[:device_config][:ip], 1, 0.2, 1])
|
|
42
|
+
code = Controller.send(:check_devices, {options: options, config: config})
|
|
43
|
+
assert_equal BAD_DEVICE, code
|
|
44
|
+
|
|
45
|
+
options = build_options({build: true, device_given: false, working: true})
|
|
46
|
+
code = Controller.send(:check_devices, {options: options, config: config})
|
|
47
|
+
assert_equal GOOD_DEVICE, code
|
|
170
48
|
end
|
|
171
|
-
logger.verify
|
|
172
49
|
end
|
|
173
|
-
end
|
|
174
50
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
51
|
+
def test_controller_run_debug
|
|
52
|
+
tests = [
|
|
53
|
+
{options: {debug: true}, method: :set_debug},
|
|
54
|
+
{options: {verbose: true}, method: :set_info},
|
|
55
|
+
{options: {}, method: :set_warn}
|
|
56
|
+
]
|
|
57
|
+
tests.each do |test|
|
|
58
|
+
logger = Minitest::Mock.new
|
|
59
|
+
logger.expect(:call, nil)
|
|
60
|
+
|
|
61
|
+
Logger.stub(test[:method], logger) do
|
|
62
|
+
Controller.initialize_logger(options: test[:options])
|
|
63
|
+
end
|
|
181
64
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Dir.stub(:exist?, exist) do
|
|
185
|
-
assert_equal RokuBuilder::MISSING_OUT_FOLDER, RokuBuilder::Controller.send(:validate_configs, configs: configs)
|
|
65
|
+
logger.verify
|
|
66
|
+
end
|
|
186
67
|
end
|
|
187
68
|
end
|
|
188
69
|
end
|