test/functional_test.rb in cerberus-0.4.5.1 vs test/functional_test.rb in cerberus-0.5
- old
+ new
@@ -4,19 +4,19 @@
require 'action_mailer'
class FunctionalTest < Test::Unit::TestCase
def setup
+ # Its better to remove on setup than teardown incase we need to debug
FileUtils.rm_rf HOME
ActionMailer::Base.deliveries.clear
end
def teardown
dir = HOME + '/../'
- 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
- # Its better to remove on setup than teardown incase we need to debug
- #FileUtils.rm_rf HOME
+ # We need change working directory to some non-removable dir otherwise we would have warning after removing that working directory absent
+ Dir.chdir(dir) if test(?d, dir)
end
def test_add_by_url
assert !File.exists?(HOME + '/config/svn_repo.yml')
@@ -43,12 +43,12 @@
assert File.exists?(project_config)
scm_conf = load_yml(project_config)['scm']
assert_equal 'svn', scm_conf['type']
scm_uri = URI.parse(scm_conf['url'])
- # TODO - this assert needs to be fixed
- #assert_match 'rubyforge.org', scm_uri.host
+ # FIXME - this assert needs to be fixed
+ # assert_match 'rubyforge.org', scm_uri.host
assert File.exists?(HOME + '/config.yml')
end
def test_build
@@ -93,11 +93,10 @@
build.run
assert !build_successful?(status_file)
assert_equal :broken, build.status.current_state
assert_equal 3, ActionMailer::Base.deliveries.size #We should receive mail if project fails
-
add_test_case_to_project('myapp', 'raise "Some exception here"') #if we have exception
build = Cerberus::BuildCommand.new('myapp', :force => true)
build.run
assert !build_successful?(status_file)
assert_equal :broken, build.status.current_state
@@ -122,11 +121,11 @@
assert build.scm.last_commit_message !~ /-rHEAD -v/
assert_equal 0, build.scm.last_commit_message.index('-' * 72)
end
def test_send_on_different_events
- #TODO - This currently throws an exit code stoping all tests
+ # FIXME - This currently throws an exit code stoping all tests
# add_application('myapp', SVN_URL, 'publisher' => {'mail' => {'on_event' => 'none'}, 'on_event' => 'all'})
# build = Cerberus::BuildCommand.new('myapp')
# build.run
# assert_equal 0, ActionMailer::Base.deliveries.size
#
@@ -198,70 +197,70 @@
assert !File.exists?(HOME + "/work/rake_cust/logs")
end
def test_darcs
- add_application('darcsapp', DARCS_URL, :scm => {:type => 'darcs'})
+ # add_application('darcsapp', DARCS_URL, :scm => {:type => 'darcs'})
- build = Cerberus::BuildCommand.new('darcsapp')
- build.run
- assert build.scm.has_changes?
- assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
- mail = ActionMailer::Base.deliveries[0]
- output = mail.body
+ # build = Cerberus::BuildCommand.new('darcsapp')
+ # build.run
+ # assert build.scm.has_changes?
+ # assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
+ # mail = ActionMailer::Base.deliveries[0]
+ # output = mail.body
- #Check outpus that run needed tasks
- assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
- assert output !~ /Task 'custom1' has been invoked/
- assert_equal '[darcsapp] Cerberus set up for project (#20061010090920)', mail.subject
+ # #Check outpus that run needed tasks
+ # assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
+ # assert output !~ /Task 'custom1' has been invoked/
+ # assert_equal '[darcsapp] Cerberus set up for project (#20061010090920)', mail.subject
- status_file = HOME + '/work/darcsapp/status.log'
- assert File.exists?(status_file)
- assert build_successful?(status_file)
- assert 1, Dir[HOME + "/work/darcsapp/logs/*.log"].size
+ # status_file = HOME + '/work/darcsapp/status.log'
+ # assert File.exists?(status_file)
+ # assert build_successful?(status_file)
+ # assert 1, Dir[HOME + "/work/darcsapp/logs/*.log"].size
- #There were no changes - no reaction should be
- build = Cerberus::BuildCommand.new('darcsapp')
- build.run
- assert_equal false, build.scm.has_changes?
- assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
- assert 1, Dir[HOME + "/work/darcsapp/logs/*.log"].size
+ # #There were no changes - no reaction should be
+ # build = Cerberus::BuildCommand.new('darcsapp')
+ # build.run
+ # assert_equal false, build.scm.has_changes?
+ # assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
+ # assert 1, Dir[HOME + "/work/darcsapp/logs/*.log"].size
- #now we add new broken test
- test_case_name = "test/#{rand(10000)}_test.rb"
- File.open(DARCS_REPO + '/' + test_case_name, 'w') { |f|
- f << "require 'test/unit'
- class A#{rand(10000)}Test < Test::Unit::TestCase
- def test_ok
- assert false
- end
- end"
- }
+ # #now we add new broken test
+ # test_case_name = "test/#{rand(10000)}_test.rb"
+ # File.open(DARCS_REPO + '/' + test_case_name, 'w') { |f|
+ # f << "require 'test/unit'
+ # class A#{rand(10000)}Test < Test::Unit::TestCase
+ # def test_ok
+ # assert false
+ # end
+ # end"
+ # }
- curr_dir = Dir.pwd
- Dir.chdir DARCS_REPO
- `darcs add #{test_case_name}`
- `darcs record -a -A test@gmail.com -m somepatch`
- Dir.chdir curr_dir
+ # curr_dir = Dir.pwd
+ # Dir.chdir DARCS_REPO
+ # `darcs add #{test_case_name}`
+ # `darcs record -a -A test@gmail.com -m somepatch`
+ # Dir.chdir curr_dir
- build = Cerberus::BuildCommand.new('darcsapp')
- build.run
- assert build.scm.has_changes?
- assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
- assert 2, Dir[HOME + "/work/darcsapp/logs/*.log"].size
+ # build = Cerberus::BuildCommand.new('darcsapp')
+ # build.run
+ # assert build.scm.has_changes?
+ # assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
+ # assert 2, Dir[HOME + "/work/darcsapp/logs/*.log"].size
- build = Cerberus::BuildCommand.new('darcsapp')
- build.run
- assert_equal false, build.scm.has_changes?
- assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
- assert 2, Dir[HOME + "/work/darcsapp/logs/*.log"].size
+ # build = Cerberus::BuildCommand.new('darcsapp')
+ # build.run
+ # assert_equal false, build.scm.has_changes?
+ # assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
+ # assert 2, Dir[HOME + "/work/darcsapp/logs/*.log"].size
- #Now we broke remote repository (imiitate that network unaccessage)
- FileUtils.rm_rf DARCS_REPO
- build = Cerberus::BuildCommand.new('darcsapp')
- build.run
- assert_equal false, build.scm.has_changes?
+ # #Now we broke remote repository (imiitate that network unaccessage)
+ # FileUtils.rm_rf DARCS_REPO
+ # build = Cerberus::BuildCommand.new('darcsapp')
+ # build.run
+ # assert_equal false, build.scm.has_changes?
end
def test_git
add_application('gitapp', GIT_URL, :scm => {:type => 'git'})
@@ -270,11 +269,11 @@
assert build.scm.has_changes?
assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
mail = ActionMailer::Base.deliveries[0]
output = mail.body
- #Check outpus that run needed tasks
+ #Check output that run needed tasks
assert_match /1 tests, 1 assertions, 0 failures, 0 errors/, output
assert output !~ /Task 'custom1' has been invoked/
assert_match /\[gitapp\] Cerberus set up for project/, mail.subject
status_file = HOME + '/work/gitapp/status.log'
@@ -288,18 +287,19 @@
assert_equal false, build.scm.has_changes?
assert_equal 1, ActionMailer::Base.deliveries.size #first email that project was setup
assert 1, Dir[HOME + "/work/gitapp/logs/*.log"].size
#now we add new broken test
- test_case_name = "test/#{rand(10000)}_test.rb"
+ rand_val = rand(10000)
+ test_case_name = "test/#{rand_val}_test.rb"
File.open(GIT_REPO + '/' + test_case_name, 'w') { |f|
- f << "require 'test/unit'
- class A#{rand(10000)}Test < Test::Unit::TestCase
+ f << %Q( require 'test/unit'
+ class A#{rand_val}Test < Test::Unit::TestCase
def test_ok
assert false
end
- end"
+ end )
}
curr_dir = Dir.pwd
Dir.chdir GIT_REPO
`git add #{test_case_name}`
@@ -307,27 +307,33 @@
Dir.chdir curr_dir
build = Cerberus::BuildCommand.new('gitapp')
build.run
assert build.scm.has_changes?
- assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
+ assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup plus new alert email
assert 2, Dir[HOME + "/work/gitsapp/logs/*.log"].size
build = Cerberus::BuildCommand.new('gitapp')
build.run
assert_equal false, build.scm.has_changes?
assert_equal 2, ActionMailer::Base.deliveries.size #first email that project was setup
assert 2, Dir[HOME + "/work/gitapp/logs/*.log"].size
- #Now we broke remote repository (imitate that network unaccessage)
+ # test git branch features
+ add_application('gitapp2', GIT_URL, 'scm' => {'type' => 'git', 'branch' => 'cerberus'})
+ build = Cerberus::BuildCommand.new('gitapp2')
+ build.run
+ assert build.scm.has_changes?
+
+ #Now we broke remote repository (imitate that network unaccessable)
FileUtils.rm_rf GIT_REPO
build = Cerberus::BuildCommand.new('gitapp')
build.run
assert_equal false, build.scm.has_changes?
end
def test_campfire_publisher
- #there were no any messages cause login/password is incorrect. We just check that there was no any exceptions
+ # there were not any messages causing login/password is incorrect. We just check that there was no any exceptions
add_application('campapp', SVN_URL, 'publisher' => {'active' => 'campfire', 'campfire' =>
{'url' => 'http://mail@gmail.com:somepwd@cerberustool.campfirenow.com/room/5166022'}
})
build = Cerberus::BuildCommand.new('campapp')