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
@@ -2,347 +2,335 @@
|
|
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
|
-
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
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
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
|
-
|
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
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
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
|
-
|
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
|
-
|
246
|
-
|
247
|
-
|
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
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
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
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
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
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
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
|
-
|