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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -2
  3. data/CHANGELOG +9 -0
  4. data/Gemfile.lock +17 -11
  5. data/bin/roku +4 -8
  6. data/lib/roku_builder.rb +16 -24
  7. data/lib/roku_builder/config.rb +213 -0
  8. data/lib/roku_builder/config_parser.rb +304 -267
  9. data/lib/roku_builder/config_validator.rb +149 -126
  10. data/lib/roku_builder/controller.rb +34 -184
  11. data/lib/roku_builder/controller_commands.rb +85 -79
  12. data/lib/roku_builder/error_handler.rb +0 -11
  13. data/lib/roku_builder/errors.rb +12 -0
  14. data/lib/roku_builder/inspector.rb +6 -4
  15. data/lib/roku_builder/keyer.rb +1 -1
  16. data/lib/roku_builder/loader.rb +1 -1
  17. data/lib/roku_builder/logger.rb +32 -0
  18. data/lib/roku_builder/manifest_manager.rb +2 -2
  19. data/lib/roku_builder/monitor.rb +1 -1
  20. data/lib/roku_builder/options.rb +113 -0
  21. data/lib/roku_builder/stager.rb +2 -2
  22. data/lib/roku_builder/tester.rb +57 -11
  23. data/lib/roku_builder/util.rb +3 -4
  24. data/lib/roku_builder/version.rb +1 -1
  25. data/roku_builder.gemspec +2 -1
  26. data/test/roku_builder/test_config.rb +168 -0
  27. data/test/roku_builder/test_config_parser.rb +347 -394
  28. data/test/roku_builder/test_config_validator.rb +193 -190
  29. data/test/roku_builder/test_controller.rb +59 -178
  30. data/test/roku_builder/test_controller_commands.rb +407 -394
  31. data/test/roku_builder/test_error_handler.rb +67 -69
  32. data/test/roku_builder/test_files/config_test/bad.json +2 -0
  33. data/test/roku_builder/test_files/config_test/child.json +11 -0
  34. data/test/roku_builder/test_files/config_test/config.json +29 -0
  35. data/test/roku_builder/test_files/config_test/non_json.json +1 -0
  36. data/test/roku_builder/test_files/config_test/parent.json +21 -0
  37. data/test/roku_builder/test_files/config_test/parent_projects.json +35 -0
  38. data/test/roku_builder/test_files/manifest_manager_test/manifest_template_2 +1 -1
  39. data/test/roku_builder/test_helper.rb +55 -45
  40. data/test/roku_builder/test_inspector.rb +278 -213
  41. data/test/roku_builder/test_keyer.rb +144 -147
  42. data/test/roku_builder/test_linker.rb +91 -95
  43. data/test/roku_builder/test_loader.rb +279 -289
  44. data/test/roku_builder/test_logger.rb +47 -0
  45. data/test/roku_builder/test_manifest_manager.rb +92 -94
  46. data/test/roku_builder/test_monitor.rb +101 -103
  47. data/test/roku_builder/test_navigator.rb +240 -245
  48. data/test/roku_builder/test_options.rb +156 -0
  49. data/test/roku_builder/test_packager.rb +108 -108
  50. data/test/roku_builder/test_profiler.rb +20 -19
  51. data/test/roku_builder/test_scripter.rb +83 -81
  52. data/test/roku_builder/test_stager.rb +299 -311
  53. data/test/roku_builder/test_tester.rb +112 -115
  54. data/test/roku_builder/test_util.rb +18 -17
  55. metadata +39 -6
  56. data/lib/roku_builder/config_manager.rb +0 -161
  57. data/test/roku_builder/test_config_manager.rb +0 -372
@@ -2,347 +2,335 @@
2
2
 
3
3
  require_relative "test_helper.rb"
4
4
 
5
- class StagerTest < Minitest::Test
6
-
7
- def test_stager_method
8
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
9
- stager_config = {
10
- method: :working,
11
- root_dir: root_dir,
12
- logger: nil
13
- }
14
- stager = RokuBuilder::Stager.new(**stager_config)
15
- assert_equal stager_config[:method], stager.method
16
- end
17
-
18
- def test_stager_stage_working
19
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
20
- stager_config = {
21
- method: :working,
22
- root_dir: root_dir,
23
- logger: nil
24
- }
25
- stager = RokuBuilder::Stager.new(**stager_config)
26
- assert stager.stage
27
- assert stager.unstage
28
- end
29
-
30
- def test_stager_stage_current
31
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
32
- stager_config = {
33
- method: :current,
34
- root_dir: root_dir,
35
- logger: nil
36
- }
37
- stager = RokuBuilder::Stager.new(**stager_config)
38
- assert stager.stage
39
- assert stager.unstage
40
- end
41
-
42
- def test_stager_stage_in
43
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
44
- stager_config = {
45
- method: :in,
46
- root_dir: root_dir,
47
- logger: nil
48
- }
49
- stager = RokuBuilder::Stager.new(**stager_config)
50
- assert stager.stage
51
- assert stager.unstage
52
- end
5
+ module RokuBuilder
6
+ class StagerTest < Minitest::Test
7
+
8
+ def test_stager_method
9
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
10
+ stager_config = {
11
+ method: :working,
12
+ root_dir: root_dir
13
+ }
14
+ stager = Stager.new(**stager_config)
15
+ assert_equal stager_config[:method], stager.method
16
+ end
53
17
 
54
- def test_stager_stage_git_stash
55
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
56
- branch_name = 'branch'
57
- git = Minitest::Mock.new
58
- branch = Minitest::Mock.new
59
- stashes = Minitest::Mock.new
60
- stash = Minitest::Mock.new
61
-
62
- stager_config = {
63
- method: :git,
64
- root_dir: root_dir,
65
- key: branch_name,
66
- logger: nil
67
- }
68
-
69
- git.expect(:current_branch, 'other_branch')
70
- git.expect(:current_branch, 'other_branch')
71
- git.expect(:branch, branch)
72
- branch.expect(:stashes, stashes)
73
- stashes.expect(:save, true, ["roku-builder-temp-stash"])
74
- git.expect(:checkout, nil, [branch_name])
75
- git.expect(:branch, branch)
76
- branch.expect(:stashes, [stash])
77
- git.expect(:checkout, nil, ['other_branch'])
78
- git.expect(:branch, branch)
79
- stash.expect(:message, "roku-builder-temp-stash")
80
- branch.expect(:stashes, stashes)
81
- stashes.expect(:pop, nil, ["stash@{0}"])
82
-
83
- Git.stub(:open, git) do
84
- stager = RokuBuilder::Stager.new(**stager_config)
18
+ def test_stager_stage_working
19
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
20
+ stager_config = {
21
+ method: :working,
22
+ root_dir: root_dir
23
+ }
24
+ stager = Stager.new(**stager_config)
85
25
  assert stager.stage
86
26
  assert stager.unstage
87
27
  end
88
- git.verify
89
- branch.verify
90
- stashes.verify
91
- stash.verify
92
- end
93
28
 
94
- def test_stager_stage_git_no_stash
95
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
96
- branch_name = 'branch'
97
- git = Minitest::Mock.new
98
- branch = Minitest::Mock.new
99
- stashes = Minitest::Mock.new
100
-
101
- stager_config = {
102
- method: :git,
103
- root_dir: root_dir,
104
- key: branch_name,
105
- logger: nil
106
- }
107
-
108
- git.expect(:current_branch, 'other_branch')
109
- git.expect(:current_branch, 'other_branch')
110
- git.expect(:branch, branch)
111
- branch.expect(:stashes, stashes)
112
- stashes.expect(:save, nil, ["roku-builder-temp-stash"])
113
- git.expect(:checkout, nil, [branch_name])
114
-
115
- git.expect(:checkout, nil, ['other_branch'])
116
- git.expect(:branch, branch)
117
- branch.expect(:stashes, [])
118
-
119
- Git.stub(:open, git) do
120
- stager = RokuBuilder::Stager.new(**stager_config)
29
+ def test_stager_stage_current
30
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
31
+ stager_config = {
32
+ method: :current,
33
+ root_dir: root_dir
34
+ }
35
+ stager = Stager.new(**stager_config)
121
36
  assert stager.stage
122
37
  assert stager.unstage
123
38
  end
124
- git.verify
125
- branch.verify
126
- stashes.verify
127
- end
128
39
 
129
- def test_stager_stage_git_error_stage
130
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
131
- branch_name = 'branch'
132
- git = Minitest::Mock.new
133
- branch = Minitest::Mock.new
134
- stashes = Minitest::Mock.new
135
- stash = Minitest::Mock.new
136
- logger = Minitest::Mock.new
137
-
138
- stager_config = {
139
- method: :git,
140
- root_dir: root_dir,
141
- key: branch_name,
142
- logger: logger
143
- }
144
-
145
- def git.checkout(branch)
146
- raise Git::GitExecuteError.new
40
+ def test_stager_stage_in
41
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
42
+ stager_config = {
43
+ method: :in,
44
+ root_dir: root_dir
45
+ }
46
+ stager = Stager.new(**stager_config)
47
+ assert stager.stage
48
+ assert stager.unstage
147
49
  end
148
50
 
149
- git.expect(:current_branch, 'other_branch')
150
- git.expect(:current_branch, 'other_branch')
151
- git.expect(:branch, branch)
152
- branch.expect(:stashes, stashes)
153
- stashes.expect(:save, true, ["roku-builder-temp-stash"])
154
- logger.expect(:error, nil, ["Branch or ref does not exist"])
155
- git.expect(:branch, branch)
156
- branch.expect(:stashes, [stash])
157
- git.expect(:branch, branch)
158
- stash.expect(:message, "roku-builder-temp-stash")
159
- branch.expect(:stashes, stashes)
160
- stashes.expect(:pop, nil, ["stash@{0}"])
161
-
162
- Git.stub(:open, git) do
163
- stager = RokuBuilder::Stager.new(**stager_config)
164
- assert !stager.stage
165
- assert stager.unstage
51
+ def test_stager_stage_git_stash
52
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
53
+ branch_name = 'branch'
54
+ git = Minitest::Mock.new
55
+ branch = Minitest::Mock.new
56
+ stashes = Minitest::Mock.new
57
+ stash = Minitest::Mock.new
58
+
59
+ stager_config = {
60
+ method: :git,
61
+ root_dir: root_dir,
62
+ key: branch_name
63
+ }
64
+
65
+ git.expect(:current_branch, 'other_branch')
66
+ git.expect(:current_branch, 'other_branch')
67
+ git.expect(:branch, branch)
68
+ branch.expect(:stashes, stashes)
69
+ stashes.expect(:save, true, ["roku-builder-temp-stash"])
70
+ git.expect(:checkout, nil, [branch_name])
71
+ git.expect(:branch, branch)
72
+ branch.expect(:stashes, [stash])
73
+ git.expect(:checkout, nil, ['other_branch'])
74
+ git.expect(:branch, branch)
75
+ stash.expect(:message, "roku-builder-temp-stash")
76
+ branch.expect(:stashes, stashes)
77
+ stashes.expect(:pop, nil, ["stash@{0}"])
78
+
79
+ Git.stub(:open, git) do
80
+ stager = Stager.new(**stager_config)
81
+ assert stager.stage
82
+ assert stager.unstage
83
+ end
84
+ git.verify
85
+ branch.verify
86
+ stashes.verify
87
+ stash.verify
166
88
  end
167
- git.verify
168
- branch.verify
169
- stashes.verify
170
- stash.verify
171
- logger.verify
172
- end
173
89
 
174
- def test_stager_stage_git_error_unstage
175
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
176
- branch_name = 'branch'
177
- git = Minitest::Mock.new
178
- logger = Minitest::Mock.new
179
-
180
- stager_config = {
181
- method: :git,
182
- root_dir: root_dir,
183
- key: branch_name,
184
- logger: logger
185
- }
186
-
187
- def git.checkout(branch)
188
- raise Git::GitExecuteError.new
90
+ def test_stager_stage_git_no_stash
91
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
92
+ branch_name = 'branch'
93
+ git = Minitest::Mock.new
94
+ branch = Minitest::Mock.new
95
+ stashes = Minitest::Mock.new
96
+
97
+ stager_config = {
98
+ method: :git,
99
+ root_dir: root_dir,
100
+ key: branch_name
101
+ }
102
+
103
+ git.expect(:current_branch, 'other_branch')
104
+ git.expect(:current_branch, 'other_branch')
105
+ git.expect(:branch, branch)
106
+ branch.expect(:stashes, stashes)
107
+ stashes.expect(:save, nil, ["roku-builder-temp-stash"])
108
+ git.expect(:checkout, nil, [branch_name])
109
+
110
+ git.expect(:checkout, nil, ['other_branch'])
111
+ git.expect(:branch, branch)
112
+ branch.expect(:stashes, [])
113
+
114
+ Git.stub(:open, git) do
115
+ stager = Stager.new(**stager_config)
116
+ assert stager.stage
117
+ assert stager.unstage
118
+ end
119
+ git.verify
120
+ branch.verify
121
+ stashes.verify
189
122
  end
190
123
 
191
- logger.expect(:error, nil, ["Branch or ref does not exist"])
124
+ def test_stager_stage_git_error_stage
125
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
126
+ branch_name = 'branch'
127
+ git = Minitest::Mock.new
128
+ branch = Minitest::Mock.new
129
+ stashes = Minitest::Mock.new
130
+ stash = Minitest::Mock.new
131
+
132
+ stager_config = {
133
+ method: :git,
134
+ root_dir: root_dir,
135
+ key: branch_name
136
+ }
137
+
138
+ def git.checkout(branch)
139
+ raise Git::GitExecuteError.new
140
+ end
192
141
 
193
- Git.stub(:open, git) do
194
- stager = RokuBuilder::Stager.new(**stager_config)
195
- stager.instance_variable_set(:@current_branch, "branch")
196
- assert !stager.unstage
142
+ git.expect(:current_branch, 'other_branch')
143
+ git.expect(:current_branch, 'other_branch')
144
+ git.expect(:branch, branch)
145
+ branch.expect(:stashes, stashes)
146
+ stashes.expect(:save, true, ["roku-builder-temp-stash"])
147
+ git.expect(:branch, branch)
148
+ branch.expect(:stashes, [stash])
149
+ git.expect(:branch, branch)
150
+ stash.expect(:message, "roku-builder-temp-stash")
151
+ branch.expect(:stashes, stashes)
152
+ stashes.expect(:pop, nil, ["stash@{0}"])
153
+
154
+ Git.stub(:open, git) do
155
+ stager = Stager.new(**stager_config)
156
+ assert !stager.stage
157
+ assert stager.unstage
158
+ end
159
+ git.verify
160
+ branch.verify
161
+ stashes.verify
162
+ stash.verify
197
163
  end
198
- git.verify
199
- logger.verify
200
- end
201
164
 
202
- def test_stager_stage_script
203
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
204
- stager_config = {
205
- method: :script,
206
- key: {stage: "stage_script", unstage: "unstage_script"},
207
- root_dir: root_dir,
208
- logger: nil
209
- }
210
- RokuBuilder::Controller.stub(:system, nil) do
211
- stager = RokuBuilder::Stager.new(**stager_config)
212
- assert stager.stage
213
- assert stager.unstage
214
- end
215
- end
165
+ def test_stager_stage_git_error_unstage
166
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
167
+ branch_name = 'branch'
168
+ git = Minitest::Mock.new
169
+ logger = Minitest::Mock.new
170
+
171
+ stager_config = {
172
+ method: :git,
173
+ root_dir: root_dir,
174
+ key: branch_name
175
+ }
176
+ Logger.class_variable_set(:@@instance, logger)
177
+
178
+ def git.checkout(branch)
179
+ raise Git::GitExecuteError.new
180
+ end
216
181
 
217
- def test_stager_save_state
218
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
219
- branch_name = 'branch'
220
- git = Minitest::Mock.new
221
- branch = Minitest::Mock.new
222
- stashes = Minitest::Mock.new
223
- pstore = Minitest::Mock.new
224
-
225
- stager_config = {
226
- method: :git,
227
- root_dir: root_dir,
228
- key: branch_name,
229
- logger: nil
230
- }
231
-
232
- git.expect(:current_branch, 'other_branch')
233
- git.expect(:current_branch, 'other_branch')
234
- git.expect(:branch, branch)
235
- branch.expect(:stashes, stashes)
236
- stashes.expect(:save, 'stash', ["roku-builder-temp-stash"])
237
- git.expect(:checkout, nil, [branch_name])
238
-
239
- pstore.expect(:transaction, nil) do |&block|
240
- block.call
241
- end
242
- pstore.expect(:[]=, nil, [:current_branch, 'other_branch'])
182
+ logger.expect(:error, nil, ["Branch or ref does not exist"])
243
183
 
184
+ Git.stub(:open, git) do
185
+ stager = Stager.new(**stager_config)
186
+ stager.instance_variable_set(:@current_branch, "branch")
187
+ assert !stager.unstage
188
+ end
189
+ git.verify
190
+ logger.verify
191
+ Logger.set_testing
192
+ end
244
193
 
245
- Git.stub(:open, git) do
246
- PStore.stub(:new, pstore) do
247
- stager = RokuBuilder::Stager.new(**stager_config)
194
+ def test_stager_stage_script
195
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
196
+ stager_config = {
197
+ method: :script,
198
+ key: {stage: "stage_script", unstage: "unstage_script"},
199
+ root_dir: root_dir
200
+ }
201
+ Controller.stub(:system, nil) do
202
+ stager = Stager.new(**stager_config)
248
203
  assert stager.stage
204
+ assert stager.unstage
249
205
  end
250
206
  end
251
- git.verify
252
- branch.verify
253
- stashes.verify
254
- pstore.verify
255
- end
256
207
 
257
- def test_stager_load_state
258
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
259
- branch_name = 'branch'
260
- git = Minitest::Mock.new
261
- branch = Minitest::Mock.new
262
- stashes = Minitest::Mock.new
263
- stash = Minitest::Mock.new
264
- pstore = Minitest::Mock.new
265
-
266
- stager_config = {
267
- method: :git,
268
- root_dir: root_dir,
269
- key: branch_name,
270
- logger: nil
271
- }
272
-
273
- pstore.expect(:transaction, nil) do |&block|
274
- block.call
275
- end
276
- git.expect(:branches, ['other_branch'])
277
- pstore.expect(:[], 'other_branch', [:current_branch])
278
- pstore.expect(:[]=, nil, [:current_branch, nil])
279
-
280
- git.expect(:branch, branch)
281
- branch.expect(:stashes, [stash])
282
- git.expect(:checkout, nil, ['other_branch'])
283
- git.expect(:branch, branch)
284
- stash.expect(:message, "roku-builder-temp-stash")
285
- branch.expect(:stashes, stashes)
286
- stashes.expect(:pop, nil, ["stash@{0}"])
287
-
288
- Git.stub(:open, git) do
289
- PStore.stub(:new, pstore) do
290
- stager = RokuBuilder::Stager.new(**stager_config)
291
- assert stager.unstage
208
+ def test_stager_save_state
209
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
210
+ branch_name = 'branch'
211
+ git = Minitest::Mock.new
212
+ branch = Minitest::Mock.new
213
+ stashes = Minitest::Mock.new
214
+ pstore = Minitest::Mock.new
215
+
216
+ stager_config = {
217
+ method: :git,
218
+ root_dir: root_dir,
219
+ key: branch_name
220
+ }
221
+
222
+ git.expect(:current_branch, 'other_branch')
223
+ git.expect(:current_branch, 'other_branch')
224
+ git.expect(:branch, branch)
225
+ branch.expect(:stashes, stashes)
226
+ stashes.expect(:save, 'stash', ["roku-builder-temp-stash"])
227
+ git.expect(:checkout, nil, [branch_name])
228
+
229
+ pstore.expect(:transaction, nil) do |&block|
230
+ block.call
231
+ end
232
+ pstore.expect(:[]=, nil, [:current_branch, 'other_branch'])
233
+
234
+
235
+ Git.stub(:open, git) do
236
+ PStore.stub(:new, pstore) do
237
+ stager = Stager.new(**stager_config)
238
+ assert stager.stage
239
+ end
292
240
  end
241
+ git.verify
242
+ branch.verify
243
+ stashes.verify
244
+ pstore.verify
293
245
  end
294
- git.verify
295
- branch.verify
296
- stashes.verify
297
- stash.verify
298
- pstore.verify
299
- end
300
246
 
301
- def test_stager_load_second_state
302
- root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
303
- branch_name = 'branch'
304
- git = Minitest::Mock.new
305
- branch = Minitest::Mock.new
306
- stashes = Minitest::Mock.new
307
- stash = Minitest::Mock.new
308
- other_stash = Minitest::Mock.new
309
- pstore = Minitest::Mock.new
310
-
311
- stager_config = {
312
- method: :git,
313
- root_dir: root_dir,
314
- key: branch_name,
315
- logger: nil
316
- }
317
-
318
- pstore.expect(:transaction, nil) do |&block|
319
- block.call
247
+ def test_stager_load_state
248
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
249
+ branch_name = 'branch'
250
+ git = Minitest::Mock.new
251
+ branch = Minitest::Mock.new
252
+ stashes = Minitest::Mock.new
253
+ stash = Minitest::Mock.new
254
+ pstore = Minitest::Mock.new
255
+
256
+ stager_config = {
257
+ method: :git,
258
+ root_dir: root_dir,
259
+ key: branch_name
260
+ }
261
+
262
+ pstore.expect(:transaction, nil) do |&block|
263
+ block.call
264
+ end
265
+ git.expect(:branches, ['other_branch'])
266
+ pstore.expect(:[], 'other_branch', [:current_branch])
267
+ pstore.expect(:[]=, nil, [:current_branch, nil])
268
+
269
+ git.expect(:branch, branch)
270
+ branch.expect(:stashes, [stash])
271
+ git.expect(:checkout, nil, ['other_branch'])
272
+ git.expect(:branch, branch)
273
+ stash.expect(:message, "roku-builder-temp-stash")
274
+ branch.expect(:stashes, stashes)
275
+ stashes.expect(:pop, nil, ["stash@{0}"])
276
+
277
+ Git.stub(:open, git) do
278
+ PStore.stub(:new, pstore) do
279
+ stager = Stager.new(**stager_config)
280
+ assert stager.unstage
281
+ end
282
+ end
283
+ git.verify
284
+ branch.verify
285
+ stashes.verify
286
+ stash.verify
287
+ pstore.verify
320
288
  end
321
- git.expect(:branches, ['other_branch'])
322
- pstore.expect(:[], 'other_branch', [:current_branch])
323
- pstore.expect(:[]=, nil, [:current_branch, nil])
324
-
325
- git.expect(:branch, branch)
326
- branch.expect(:stashes, [other_stash, stash])
327
- git.expect(:checkout, nil, ['other_branch'])
328
- git.expect(:branch, branch)
329
- stash.expect(:message, "roku-builder-temp-stash")
330
- other_stash.expect(:message, "random_messgae")
331
- branch.expect(:stashes, stashes)
332
- stashes.expect(:pop, nil, ["stash@{1}"])
333
-
334
- Git.stub(:open, git) do
335
- PStore.stub(:new, pstore) do
336
- stager = RokuBuilder::Stager.new(**stager_config)
337
- assert stager.unstage
289
+
290
+ def test_stager_load_second_state
291
+ root_dir = File.join(File.dirname(__FILE__), "test_files", "stager_test")
292
+ branch_name = 'branch'
293
+ git = Minitest::Mock.new
294
+ branch = Minitest::Mock.new
295
+ stashes = Minitest::Mock.new
296
+ stash = Minitest::Mock.new
297
+ other_stash = Minitest::Mock.new
298
+ pstore = Minitest::Mock.new
299
+
300
+ stager_config = {
301
+ method: :git,
302
+ root_dir: root_dir,
303
+ key: branch_name
304
+ }
305
+
306
+ pstore.expect(:transaction, nil) do |&block|
307
+ block.call
338
308
  end
309
+ git.expect(:branches, ['other_branch'])
310
+ pstore.expect(:[], 'other_branch', [:current_branch])
311
+ pstore.expect(:[]=, nil, [:current_branch, nil])
312
+
313
+ git.expect(:branch, branch)
314
+ branch.expect(:stashes, [other_stash, stash])
315
+ git.expect(:checkout, nil, ['other_branch'])
316
+ git.expect(:branch, branch)
317
+ stash.expect(:message, "roku-builder-temp-stash")
318
+ other_stash.expect(:message, "random_messgae")
319
+ branch.expect(:stashes, stashes)
320
+ stashes.expect(:pop, nil, ["stash@{1}"])
321
+
322
+ Git.stub(:open, git) do
323
+ PStore.stub(:new, pstore) do
324
+ stager = Stager.new(**stager_config)
325
+ assert stager.unstage
326
+ end
327
+ end
328
+ git.verify
329
+ branch.verify
330
+ stashes.verify
331
+ stash.verify
332
+ other_stash.verify
333
+ pstore.verify
339
334
  end
340
- git.verify
341
- branch.verify
342
- stashes.verify
343
- stash.verify
344
- other_stash.verify
345
- pstore.verify
346
335
  end
347
336
  end
348
-