flash_flow 1.3.2.1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +0,0 @@
1
- module FlashFlow
2
- module MergeMaster
3
- end
4
- end
5
-
6
- require 'flash_flow/merge_master/status'
@@ -1,186 +0,0 @@
1
- require 'minitest_helper'
2
- require 'minitest/stub_any_instance'
3
-
4
- module FlashFlow
5
- class TestDeploy < Minitest::Test
6
-
7
- def setup
8
- reset_config!
9
- config!(git: {
10
- 'merge_branch' => 'test_acceptance',
11
- 'merge_remote' => 'test_remote',
12
- 'master_branch' => 'test_master',
13
- 'remotes' => ['fake_origin'],
14
- 'use_rerere' => true
15
- })
16
-
17
- @branch = Data::Branch.from_hash({'ref' => 'pushing_branch', 'remote' => 'origin', 'status' => 'fail', 'stories' => []})
18
- @deploy = Deploy.new
19
- end
20
-
21
- def test_version_is_nil
22
- with_versions('1.1.1', nil) do
23
- assert_nil(@deploy.check_version)
24
- end
25
- end
26
-
27
- def test_check_version_greater
28
- with_versions('2.0.0', '1.1.1') do
29
- assert_nil(@deploy.check_version)
30
- end
31
-
32
- with_versions('1.2.0', '1.1.1') do
33
- assert_nil(@deploy.check_version)
34
- end
35
- end
36
-
37
- def test_check_version_less_raises
38
- with_versions('1.1.1', '2.1.0') do
39
- assert_raises(RuntimeError) { @deploy.check_version }
40
- end
41
-
42
- with_versions('1.2.0', '2.1.0') do
43
- assert_raises(RuntimeError) { @deploy.check_version }
44
- end
45
- end
46
-
47
- def test_check_version_equal
48
-
49
- end
50
-
51
- def test_print_errors_with_no_errors
52
- data.expect(:failures, [])
53
- assert_equal(@deploy.format_errors, 'Success!')
54
- end
55
-
56
- def test_print_errors_when_current_branch_cant_merge
57
- data.expect(:failures, [@branch])
58
- @branch.fail!('some_random_sha')
59
-
60
- current_branch_error = "ERROR: Your branch did not merge to test_acceptance. Run 'flash_flow --resolve', fix the merge conflict(s) and then re-run this script\n"
61
-
62
- @deploy.instance_variable_get('@local_git'.to_sym).stub(:working_branch, 'pushing_branch') do
63
- assert_equal(current_branch_error, @deploy.format_errors)
64
- end
65
- end
66
-
67
- def test_print_errors_when_another_branch_cant_merge
68
- data.expect(:failures, [@branch])
69
-
70
- other_branch_error = "WARNING: Unable to merge branch origin/pushing_branch to test_acceptance due to conflicts."
71
-
72
- assert_equal(@deploy.format_errors, other_branch_error)
73
- end
74
-
75
- def test_check_out_to_working_branch
76
- @deploy.stub(:check_repo, true) do
77
- @deploy.stub(:check_version, true) do
78
- Lock::Base.stub_any_instance(:with_lock, -> { raise Lock::Error }) do
79
- assert_output(/Failure!/) { @deploy.run }
80
- end
81
- end
82
- end
83
- end
84
-
85
- def test_deleted_branch
86
- data.expect(:mark_deleted, true, [@branch])
87
-
88
- notifier.expect(:deleted_branch, true, [@branch])
89
-
90
- merger.expect(:result, :deleted)
91
-
92
- @deploy.process_result(@branch, merger)
93
-
94
- notifier.verify
95
- data.verify
96
- merger.verify
97
- end
98
-
99
- def test_merge_conflict
100
- data.expect(:mark_failure, true, [@branch, nil])
101
-
102
- notifier.expect(:merge_conflict, true, [@branch])
103
-
104
- merger.expect(:result, :conflict)
105
-
106
- @deploy.process_result(@branch, merger)
107
-
108
- notifier.verify
109
- data.verify
110
- merger.verify
111
- end
112
-
113
- def test_successful_merge
114
- data.expect(:mark_success, true, [@branch])
115
- data.expect(:set_resolutions, true, [ @branch, { 'filename' => ["resolution_sha"] } ])
116
-
117
- merger.
118
- expect(:result, :success).
119
- expect(:sha, 'sha').
120
- expect(:resolutions, { 'filename' => ["resolution_sha"] })
121
-
122
- @deploy.process_result(@branch, merger)
123
-
124
- data.verify
125
- merger.verify
126
- assert_equal(@branch.sha, 'sha')
127
- end
128
-
129
- def test_ignore_pushing_master_or_acceptance
130
- ['test_master', 'test_acceptance'].each do |branch|
131
- @deploy.instance_variable_get('@local_git'.to_sym).stub(:working_branch, branch) do
132
- refute(@deploy.open_pull_request)
133
- end
134
- end
135
- end
136
-
137
- def test_commit_message_ordering
138
- data
139
- .expect(:successes, ['data_successes'])
140
- .expect(:successes, sample_branches)
141
- .expect(:failures, [])
142
- .expect(:removals, [])
143
-
144
- expected_message = sample_branches.sort_by(&:merge_order).map(&:ref).join("\n")
145
- assert_output(/#{expected_message}/) { print @deploy.commit_message }
146
- data.verify
147
- end
148
-
149
- private
150
-
151
- def with_versions(current, written)
152
- original_version = FlashFlow::VERSION
153
- FlashFlow.send(:remove_const, :VERSION)
154
- FlashFlow.const_set(:VERSION, current)
155
- data.expect(:version, written)
156
- yield
157
- data.verify
158
- FlashFlow.send(:remove_const, :VERSION)
159
- FlashFlow.const_set(:VERSION, original_version)
160
- end
161
-
162
- def merger
163
- @merger ||= Minitest::Mock.new
164
- end
165
-
166
- def notifier
167
- return @notifier if @notifier
168
-
169
- @notifier = Minitest::Mock.new
170
- @deploy.instance_variable_set('@notifier'.to_sym, @notifier)
171
- end
172
-
173
- def data
174
- return @data if @data
175
-
176
- @data = Minitest::Mock.new
177
- @deploy.instance_variable_set('@data'.to_sym, @data)
178
- end
179
-
180
- def sample_branches
181
- @sample_branches ||= [Data::Branch.from_hash({'ref' => 'branch3', 'merge_order' => 2}),
182
- Data::Branch.from_hash({'ref' => 'branch1', 'merge_order' => 3}),
183
- Data::Branch.from_hash({'ref' => 'branch2', 'merge_order' => 1})]
184
- end
185
- end
186
- end