cerberus 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +159 -129
- data/LICENSE +21 -21
- data/README +75 -75
- data/Rakefile +161 -159
- data/bin/cerberus +2 -2
- data/lib/cerberus/builder/maven2.rb +38 -38
- data/lib/cerberus/builder/rake.rb +7 -7
- data/lib/cerberus/builder/rant.rb +7 -7
- data/lib/cerberus/builder/rspec.rb +13 -0
- data/lib/cerberus/builder/ruby_base.rb +48 -47
- data/lib/cerberus/cli.rb +73 -70
- data/lib/cerberus/component_lazy_loader.rb +2 -0
- data/lib/cerberus/config.example.yml +28 -28
- data/lib/cerberus/config.rb +47 -46
- data/lib/cerberus/constants.rb +8 -8
- data/lib/cerberus/latch.rb +26 -26
- data/lib/cerberus/manager.rb +296 -267
- data/lib/cerberus/publisher/base.rb +47 -47
- data/lib/cerberus/publisher/gmailer.rb +17 -0
- data/lib/cerberus/publisher/irc.rb +27 -27
- data/lib/cerberus/publisher/jabber.rb +25 -25
- data/lib/cerberus/publisher/mail.rb +36 -36
- data/lib/cerberus/publisher/netsmtp_tls_fix.rb +66 -66
- data/lib/cerberus/publisher/rss.rb +27 -28
- data/lib/cerberus/scm/cvs.rb +48 -48
- data/lib/cerberus/scm/darcs.rb +70 -70
- data/lib/cerberus/scm/svn.rb +83 -83
- data/lib/cerberus/utils.rb +156 -156
- data/test/config_test.rb +45 -45
- data/test/functional_test.rb +288 -287
- data/test/integration_test.rb +104 -104
- data/test/irc_publisher_test.rb +18 -18
- data/test/jabber_publisher_test.rb +21 -21
- data/test/mail_publisher_test.rb +25 -25
- data/test/maven2_builer_test.rb +81 -81
- data/test/mock/irc.rb +20 -20
- data/test/mock/manager.rb +10 -10
- data/test/mock/xmpp4r.rb +19 -19
- data/test/rss_publisher_test.rb +21 -21
- data/test/test_helper.rb +105 -105
- metadata +58 -40
- data/lib/cerberus/helper/xchar.rb +0 -61
data/test/config_test.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
require 'cerberus/config'
|
4
|
-
|
5
|
-
class ConfigTest < Test::Unit::TestCase
|
6
|
-
def test_config
|
7
|
-
dump_yml(HOME + "/config.yml", {'a'=>'conf', 'd'=>'conf', 'm' => 'conf'})
|
8
|
-
dump_yml(HOME + "/config/abra.yml", {'a'=>'app', 'd'=>'app', 'g' => 'app'})
|
9
|
-
cfg = Cerberus::Config.new('abra', :a => 'cli', :b=>'cli', :e=>'cli')
|
10
|
-
|
11
|
-
assert_equal nil, cfg[:mamba]
|
12
|
-
assert_equal 'cli', cfg[:a]
|
13
|
-
assert_equal 'cli', cfg[:b]
|
14
|
-
assert_equal 'app', cfg[:d]
|
15
|
-
assert_equal 'app', cfg[:g]
|
16
|
-
assert_equal 'conf', cfg[:m]
|
17
|
-
|
18
|
-
|
19
|
-
assert_equal nil, cfg['mamba']
|
20
|
-
assert_equal 'cli', cfg['a']
|
21
|
-
assert_equal 'cli', cfg['b']
|
22
|
-
assert_equal 'app', cfg['d']
|
23
|
-
assert_equal 'app', cfg['g']
|
24
|
-
assert_equal 'conf', cfg['m']
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_deep_merge
|
28
|
-
cfg = Cerberus::Config.new
|
29
|
-
cfg.merge!(:hello => {'msg' => {:a202 => 'bye'}})
|
30
|
-
cfg.merge!(:hello => {:msg => {:a203 => 'hello'}})
|
31
|
-
cfg.merge!(:hello => {:msg => {:a203 => 'another'}})
|
32
|
-
cfg.merge!(:hello => {:bread => {:a204 => 'bread'}})
|
33
|
-
|
34
|
-
assert_equal 'bye', cfg[:hello, :msg, :a202]
|
35
|
-
assert_equal 'another', cfg[:hello, :msg, :a203]
|
36
|
-
assert_equal 'bread', cfg[:hello, :bread, :a204]
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_deep_merge_not_overwrite
|
40
|
-
cfg = Cerberus::Config.new
|
41
|
-
cfg.merge!({:hello => {'msg' => {:a202 => 'bye'}}}, false)
|
42
|
-
cfg.merge!({:hello => {:msg => {:a202 => 'hello'}}}, false)
|
43
|
-
|
44
|
-
assert_equal 'bye', cfg[:hello, :msg, :a202]
|
45
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
require 'cerberus/config'
|
4
|
+
|
5
|
+
class ConfigTest < Test::Unit::TestCase
|
6
|
+
def test_config
|
7
|
+
dump_yml(HOME + "/config.yml", {'a'=>'conf', 'd'=>'conf', 'm' => 'conf'})
|
8
|
+
dump_yml(HOME + "/config/abra.yml", {'a'=>'app', 'd'=>'app', 'g' => 'app'})
|
9
|
+
cfg = Cerberus::Config.new('abra', :a => 'cli', :b=>'cli', :e=>'cli')
|
10
|
+
|
11
|
+
assert_equal nil, cfg[:mamba]
|
12
|
+
assert_equal 'cli', cfg[:a]
|
13
|
+
assert_equal 'cli', cfg[:b]
|
14
|
+
assert_equal 'app', cfg[:d]
|
15
|
+
assert_equal 'app', cfg[:g]
|
16
|
+
assert_equal 'conf', cfg[:m]
|
17
|
+
|
18
|
+
|
19
|
+
assert_equal nil, cfg['mamba']
|
20
|
+
assert_equal 'cli', cfg['a']
|
21
|
+
assert_equal 'cli', cfg['b']
|
22
|
+
assert_equal 'app', cfg['d']
|
23
|
+
assert_equal 'app', cfg['g']
|
24
|
+
assert_equal 'conf', cfg['m']
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_deep_merge
|
28
|
+
cfg = Cerberus::Config.new
|
29
|
+
cfg.merge!(:hello => {'msg' => {:a202 => 'bye'}})
|
30
|
+
cfg.merge!(:hello => {:msg => {:a203 => 'hello'}})
|
31
|
+
cfg.merge!(:hello => {:msg => {:a203 => 'another'}})
|
32
|
+
cfg.merge!(:hello => {:bread => {:a204 => 'bread'}})
|
33
|
+
|
34
|
+
assert_equal 'bye', cfg[:hello, :msg, :a202]
|
35
|
+
assert_equal 'another', cfg[:hello, :msg, :a203]
|
36
|
+
assert_equal 'bread', cfg[:hello, :bread, :a204]
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_deep_merge_not_overwrite
|
40
|
+
cfg = Cerberus::Config.new
|
41
|
+
cfg.merge!({:hello => {'msg' => {:a202 => 'bye'}}}, false)
|
42
|
+
cfg.merge!({:hello => {:msg => {:a202 => 'hello'}}}, false)
|
43
|
+
|
44
|
+
assert_equal 'bye', cfg[:hello, :msg, :a202]
|
45
|
+
end
|
46
46
|
end
|
data/test/functional_test.rb
CHANGED
@@ -1,287 +1,288 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
require 'mock/marshmallow'
|
3
|
-
require 'cerberus/cli'
|
4
|
-
|
5
|
-
require 'action_mailer'
|
6
|
-
|
7
|
-
class FunctionalTest < Test::Unit::TestCase
|
8
|
-
def setup
|
9
|
-
FileUtils.rm_rf HOME
|
10
|
-
ActionMailer::Base.deliveries.clear
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
command.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
assert_equal
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
command.
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
build.
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
assert
|
66
|
-
assert
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
build.
|
71
|
-
|
72
|
-
assert
|
73
|
-
|
74
|
-
assert_equal
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
build.
|
79
|
-
|
80
|
-
assert_equal
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
build.
|
88
|
-
|
89
|
-
|
90
|
-
assert_equal
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
build.
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
build.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
build.
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
build.
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
build.
|
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
|
-
add_application('
|
164
|
-
add_application('
|
165
|
-
add_application('
|
166
|
-
|
167
|
-
|
168
|
-
build.
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
assert
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
build.
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
assert_match /Task '
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
build.
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
build.
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
assert
|
213
|
-
assert
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
build.
|
218
|
-
|
219
|
-
assert_equal
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
Dir.
|
235
|
-
|
236
|
-
`darcs
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
build.
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
build.
|
247
|
-
|
248
|
-
assert_equal
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
build.
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
build.
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
assert_equal nil, status.
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
assert_equal
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
assert_equal
|
285
|
-
assert_equal
|
286
|
-
|
287
|
-
end
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'mock/marshmallow'
|
3
|
+
require 'cerberus/cli'
|
4
|
+
|
5
|
+
require 'action_mailer'
|
6
|
+
|
7
|
+
class FunctionalTest < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
FileUtils.rm_rf HOME
|
10
|
+
ActionMailer::Base.deliveries.clear
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
dir = HOME + '/../'
|
15
|
+
Dir.chdir(dir) if test(?d, dir) #We need change working directory to some non-removable dir otherwise we would have warning after removing that working directory absent
|
16
|
+
FileUtils.rm_rf HOME
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_add_by_url
|
20
|
+
assert !File.exists?(HOME + '/config/svn_repo.yml')
|
21
|
+
|
22
|
+
command = Cerberus::AddCommand.new(" #{SVN_URL} ", :quiet => true)
|
23
|
+
command.run
|
24
|
+
|
25
|
+
assert File.exists?(HOME + '/config/svn_repo.yml')
|
26
|
+
scm_conf = load_yml(HOME + '/config/svn_repo.yml')['scm']
|
27
|
+
assert_equal 'svn', scm_conf['type']
|
28
|
+
assert_equal SVN_URL, scm_conf['url']
|
29
|
+
|
30
|
+
assert File.exists?(HOME + '/config.yml')
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_add_by_dir
|
34
|
+
sources_dir = File.dirname(__FILE__) + '/..'
|
35
|
+
|
36
|
+
command = Cerberus::AddCommand.new(sources_dir, :quiet => true)
|
37
|
+
command.run
|
38
|
+
|
39
|
+
project_config = HOME + "/config/#{File.basename(File.expand_path(sources_dir))}.yml" #name of added application should be calculated from File System path
|
40
|
+
|
41
|
+
assert File.exists?(project_config)
|
42
|
+
scm_conf = load_yml(project_config)['scm']
|
43
|
+
assert_equal 'svn', scm_conf['type']
|
44
|
+
assert_match %r{svn(\+ssh)?://(\w+@)?rubyforge.org/var/svn/cerberus}, scm_conf['url']
|
45
|
+
|
46
|
+
assert File.exists?(HOME + '/config.yml')
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_build
|
50
|
+
add_application('myapp', SVN_URL)
|
51
|
+
|
52
|
+
build = Cerberus::BuildCommand.new('myapp', :changeset_url => 'http://someurl.changeset.com/')
|
53
|
+
build.run
|
54
|
+
assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
|
55
|
+
mail = ActionMailer::Base.deliveries[0]
|
56
|
+
output = mail.body
|
57
|
+
|
58
|
+
#Check outpus that run needed tasks
|
59
|
+
assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
|
60
|
+
assert output !~ /Task 'custom1' has been invoked/
|
61
|
+
assert_equal '[myapp] Cerberus set up for project (#2)', mail.subject
|
62
|
+
assert output =~ %r{http://someurl.changeset.com/2}
|
63
|
+
|
64
|
+
status_file = HOME + '/work/myapp/status.log'
|
65
|
+
assert File.exists?(status_file)
|
66
|
+
assert build_successful?(status_file)
|
67
|
+
assert 1, Dir[HOME + "/work/rake_cust/logs/*-setup.log"].size
|
68
|
+
|
69
|
+
FileUtils.rm status_file
|
70
|
+
build = Cerberus::BuildCommand.new('myapp')
|
71
|
+
build.run
|
72
|
+
assert File.exists?(status_file)
|
73
|
+
assert build_successful?(status_file)
|
74
|
+
assert_equal :setup, build.status.current_state
|
75
|
+
assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
|
76
|
+
assert 2, Dir[HOME + "/work/rake_cust/logs/*.log"].size
|
77
|
+
|
78
|
+
build = Cerberus::BuildCommand.new('myapp', :force => true)
|
79
|
+
build.run
|
80
|
+
assert_equal :successful, build.status.current_state
|
81
|
+
assert_equal 2, ActionMailer::Base.deliveries.size #Number of mails not changed
|
82
|
+
assert 2, Dir[HOME + "/work/rake_cust/logs/*.log"].size #even if sources unchanged
|
83
|
+
|
84
|
+
#remove status file to run project again
|
85
|
+
FileUtils.rm status_file
|
86
|
+
add_test_case_to_project('myapp', 'assert false') #if assertion failed
|
87
|
+
build = Cerberus::BuildCommand.new('myapp')
|
88
|
+
build.run
|
89
|
+
assert !build_successful?(status_file)
|
90
|
+
assert_equal :broken, build.status.current_state
|
91
|
+
assert_equal 3, ActionMailer::Base.deliveries.size #We should receive mail if project fails
|
92
|
+
|
93
|
+
|
94
|
+
add_test_case_to_project('myapp', 'raise "Some exception here"') #if we have exception
|
95
|
+
build = Cerberus::BuildCommand.new('myapp', :force => true)
|
96
|
+
build.run
|
97
|
+
assert !build_successful?(status_file)
|
98
|
+
assert_equal :broken, build.status.current_state
|
99
|
+
|
100
|
+
subject = ActionMailer::Base.deliveries.last.subject
|
101
|
+
assert_match /and getting worse/, subject
|
102
|
+
|
103
|
+
#remove status file to run project again
|
104
|
+
FileUtils.rm status_file
|
105
|
+
build = Cerberus::BuildCommand.new('myapp')
|
106
|
+
build.run
|
107
|
+
assert !build_successful?(status_file)
|
108
|
+
assert_equal :broken, build.status.current_state
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_have_no_awkward_header
|
112
|
+
add_application('myapp', SVN_URL, 'publisher' => {'active' => 'mail'})
|
113
|
+
|
114
|
+
build = Cerberus::BuildCommand.new('myapp')
|
115
|
+
build.run
|
116
|
+
|
117
|
+
assert build.scm.last_commit_message !~ /-rHEAD -v/
|
118
|
+
assert_equal 0, build.scm.last_commit_message.index('-' * 72)
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_send_on_different_events
|
122
|
+
add_application('myapp', SVN_URL, 'publisher' => {'mail' => {'on_event' => 'none'}, 'on_event' => 'all'})
|
123
|
+
build = Cerberus::BuildCommand.new('myapp')
|
124
|
+
build.run
|
125
|
+
assert_equal 0, ActionMailer::Base.deliveries.size
|
126
|
+
|
127
|
+
|
128
|
+
add_application('myapp', SVN_URL, 'publisher' => {'mail' => {'on_event' => 'all'}, 'on_event' => 'none'})
|
129
|
+
build = Cerberus::BuildCommand.new('myapp')
|
130
|
+
build.run
|
131
|
+
assert_equal 1, ActionMailer::Base.deliveries.size
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_multiply_publishers_without_configuration
|
135
|
+
add_application('myapp', SVN_URL, 'publisher' => {'active' => 'mail , jabber , irc, dddd'})
|
136
|
+
|
137
|
+
build = Cerberus::BuildCommand.new('myapp')
|
138
|
+
|
139
|
+
begin
|
140
|
+
build.run
|
141
|
+
rescue RuntimeError => e
|
142
|
+
assert_equal 'Publisher have no configuration: jabber', e.message
|
143
|
+
else
|
144
|
+
assert false
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_application_and_config_together
|
149
|
+
add_config('publisher' => {'active' => 'jabber'})
|
150
|
+
add_application('myapp', SVN_URL)
|
151
|
+
build = Cerberus::BuildCommand.new('myapp')
|
152
|
+
|
153
|
+
begin
|
154
|
+
build.run
|
155
|
+
rescue RuntimeError => e
|
156
|
+
assert_equal 'Publisher have no configuration: jabber', e.message
|
157
|
+
else
|
158
|
+
assert false
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_batch_running
|
163
|
+
add_application('myapp1', SVN_URL)
|
164
|
+
add_application('myapp2', SVN_URL)
|
165
|
+
add_application('myapp3', SVN_URL)
|
166
|
+
add_application('myapp4', SVN_URL)
|
167
|
+
|
168
|
+
build = Cerberus::BuildAllCommand.new
|
169
|
+
build.run
|
170
|
+
|
171
|
+
for i in 1..4 do
|
172
|
+
status_file = HOME + "/work/myapp#{i}/status.log"
|
173
|
+
assert File.exists?(status_file)
|
174
|
+
assert build_successful?(status_file)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_custom_task_for_rake
|
179
|
+
add_application('rake_cust', SVN_URL, 'builder' => {'rake' => {'task' => 'custom1 custom2'}})
|
180
|
+
build = Cerberus::BuildAllCommand.new
|
181
|
+
build.run
|
182
|
+
assert_equal 1, ActionMailer::Base.deliveries.size
|
183
|
+
output = ActionMailer::Base.deliveries[0].body
|
184
|
+
assert_match /Task 'custom1' has been invoked/, output
|
185
|
+
assert_match /Task 'custom2' has been invoked/, output
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_logs_disabled
|
189
|
+
add_application('rake_cust', SVN_URL, 'log' => {'enable' => false})
|
190
|
+
build = Cerberus::BuildAllCommand.new
|
191
|
+
build.run
|
192
|
+
|
193
|
+
assert !File.exists?(HOME + "/work/rake_cust/logs")
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_darcs
|
197
|
+
add_application('darcsapp', DARCS_URL, :scm => {:type => 'darcs'})
|
198
|
+
|
199
|
+
build = Cerberus::BuildCommand.new('darcsapp')
|
200
|
+
build.run
|
201
|
+
assert build.scm.has_changes?
|
202
|
+
assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
|
203
|
+
mail = ActionMailer::Base.deliveries[0]
|
204
|
+
output = mail.body
|
205
|
+
|
206
|
+
#Check outpus that run needed tasks
|
207
|
+
assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
|
208
|
+
assert output !~ /Task 'custom1' has been invoked/
|
209
|
+
assert_equal '[darcsapp] Cerberus set up for project (#20061010090920)', mail.subject
|
210
|
+
|
211
|
+
status_file = HOME + '/work/darcsapp/status.log'
|
212
|
+
assert File.exists?(status_file)
|
213
|
+
assert build_successful?(status_file)
|
214
|
+
assert 1, Dir[HOME + "/work/darcsapp/logs/*.log"].size
|
215
|
+
|
216
|
+
#There were no changes - no reaction should be
|
217
|
+
build = Cerberus::BuildCommand.new('darcsapp')
|
218
|
+
build.run
|
219
|
+
assert_equal false, build.scm.has_changes?
|
220
|
+
assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
|
221
|
+
assert 1, Dir[HOME + "/work/darcsapp/logs/*.log"].size
|
222
|
+
|
223
|
+
#now we add new broken test
|
224
|
+
test_case_name = "test/#{rand(10000)}_test.rb"
|
225
|
+
File.open(DARCS_REPO + '/' + test_case_name, 'w') { |f|
|
226
|
+
f << "require 'test/unit'
|
227
|
+
class A#{rand(10000)}Test < Test::Unit::TestCase
|
228
|
+
def test_ok
|
229
|
+
assert false
|
230
|
+
end
|
231
|
+
end"
|
232
|
+
}
|
233
|
+
|
234
|
+
curr_dir = Dir.pwd
|
235
|
+
Dir.chdir DARCS_REPO
|
236
|
+
`darcs add #{test_case_name}`
|
237
|
+
`darcs record -a -A test@gmail.com -m somepatch`
|
238
|
+
Dir.chdir curr_dir
|
239
|
+
|
240
|
+
build = Cerberus::BuildCommand.new('darcsapp')
|
241
|
+
build.run
|
242
|
+
assert build.scm.has_changes?
|
243
|
+
assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
|
244
|
+
assert 2, Dir[HOME + "/work/darcsapp/logs/*.log"].size
|
245
|
+
|
246
|
+
build = Cerberus::BuildCommand.new('darcsapp')
|
247
|
+
build.run
|
248
|
+
assert_equal false, build.scm.has_changes?
|
249
|
+
assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
|
250
|
+
assert 2, Dir[HOME + "/work/darcsapp/logs/*.log"].size
|
251
|
+
|
252
|
+
#Now we broke remote repository (imiitate that network unaccessage)
|
253
|
+
FileUtils.rm_rf DARCS_REPO
|
254
|
+
build = Cerberus::BuildCommand.new('darcsapp')
|
255
|
+
build.run
|
256
|
+
assert_equal false, build.scm.has_changes?
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_campfire_publisher
|
260
|
+
#there were no any messages cause login/password is incorrect. We just check that there was no any exceptions
|
261
|
+
add_application('campapp', SVN_URL, 'publisher' => {'active' => 'campfire', 'campfire' =>
|
262
|
+
{'url' => 'http://mail@gmail.com:somepwd@cerberustool.campfirenow.com/room/5166022'}
|
263
|
+
})
|
264
|
+
|
265
|
+
build = Cerberus::BuildCommand.new('campapp')
|
266
|
+
build.run
|
267
|
+
|
268
|
+
assert_equal 2, Marshmallow.counter
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_correct_migration_from_previous_status
|
272
|
+
status_fn = TEMP_DIR + '/test_status_file.log'
|
273
|
+
|
274
|
+
status = Cerberus::Status.new(status_fn)
|
275
|
+
assert_equal nil, status.previous_build_successful
|
276
|
+
assert_equal nil, status.current_build_successful
|
277
|
+
|
278
|
+
IO.write(status_fn, 'failed')
|
279
|
+
status = Cerberus::Status.new(status_fn)
|
280
|
+
assert_equal nil, status.current_build_successful
|
281
|
+
assert_equal false, status.previous_build_successful
|
282
|
+
|
283
|
+
status.keep(true, 1232, 0)
|
284
|
+
assert_equal true, status.current_build_successful
|
285
|
+
assert_equal false, status.previous_build_successful
|
286
|
+
assert_equal :revival, status.current_state
|
287
|
+
end
|
288
|
+
end
|