Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Commit

Permalink
test: Added missing tests to boost up coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgon committed Mar 17, 2018
1 parent b92417f commit 77f569c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
18 changes: 17 additions & 1 deletion spec/unit/recipes/deploy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
'purge_before_symlink' => %w[log tmp/cache tmp/pids public/system public/assets public/test]
)

expect(chef_run).to disable_logrotate_app('rails')
expect(chef_run).to run_execute('stop unicorn')
expect(chef_run).to run_execute('start unicorn')
expect(deploy).to notify('service[nginx]').to(:reload).delayed
Expand Down Expand Up @@ -182,6 +183,13 @@
)
end

it 'creates temporary archive directories' do
expect(chef_run).to run_ruby_block('extract')
expect(chef_run).to create_directory(tmpdir)
expect(chef_run).to create_directory(File.join(tmpdir, 'archive'))
expect(chef_run).to create_directory(File.join(tmpdir, 'archive.d'))
end

it 'creates dummy git repository' do
expect(chef_run).to run_execute(
"cd #{File.join(tmpdir, 'archive.d')} && git init && " \
Expand Down Expand Up @@ -257,6 +265,12 @@
)
end

it 'creates temporary archive directories' do
expect(chef_run).to create_directory(tmpdir)
expect(chef_run).to create_directory(File.join(tmpdir, 'archive'))
expect(chef_run).to create_directory(File.join(tmpdir, 'archive.d'))
end

it 'creates dummy git repository' do
expect(chef_run).to run_execute(
"cd #{File.join(tmpdir, 'archive.d')} && git init && " \
Expand Down Expand Up @@ -304,17 +318,18 @@
end.converge(described_recipe)
service = chef_run.service('puma_a1')

expect(chef_run).to create_directory('/run/lock/a1')
expect(chef_run).to create_directory('/srv/www/a1/shared')
expect(chef_run).to create_directory('/srv/www/a1/shared/config')
expect(chef_run).to create_directory('/srv/www/a1/shared/log')
expect(chef_run).to create_directory('/run/lock/a1')
expect(chef_run).to create_directory('/srv/www/a1/shared/scripts')
expect(chef_run).to create_directory('/srv/www/a1/shared/sockets')
expect(chef_run).to create_directory('/srv/www/a1/shared/vendor/bundle')
expect(chef_run).to create_template('/srv/www/a1/shared/config/database.yml')
expect(chef_run).to create_template('/srv/www/a1/shared/config/puma.rb')
expect(chef_run).to create_template('/srv/www/a1/shared/scripts/puma.service')
expect(chef_run).to create_template('/etc/nginx/sites-available/a1.conf')
expect(chef_run).to create_link('/srv/www/a1/shared/pids')
expect(chef_run).to create_link('/etc/nginx/sites-enabled/a1.conf')
expect(chef_run).to enable_logrotate_app('a1-nginx-production')
expect(chef_run).to enable_logrotate_app('a1-rails-production')
Expand Down Expand Up @@ -367,6 +382,7 @@
expect(chef_run).to create_directory('/some/other/path/to/a1/shared/sockets')
expect(chef_run).to create_directory('/some/other/path/to/a1/shared/vendor/bundle')
expect(chef_run).to create_directory('/run/lock/a1')
expect(chef_run).to create_link('/some/other/path/to/a1/shared/pids')
expect(chef_run).to create_template('/some/other/path/to/a1/shared/config/database.yml')
expect(chef_run).to create_template('/some/other/path/to/a1/shared/config/puma.rb')
expect(chef_run).to create_template('/some/other/path/to/a1/shared/scripts/puma.service')
Expand Down
18 changes: 18 additions & 0 deletions spec/unit/recipes/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,19 @@
end
end

context 'debian preparations' do
it 'javascript-common' do
expect(chef_run).to purge_apt_package('javascript-common')
end

it 'monit' do
expect(chef_run).to run_execute('mkdir -p /etc/monit/conf.d')
expect(chef_run).to create_file('/etc/monit/conf.d/00_httpd.monitrc').with(
content: "set httpd port 2812 and\n use address localhost\n allow localhost"
)
end
end

context 'epel' do
it 'rhel' do
expect(chef_run_rhel).to run_execute('yum-config-manager --enable epel')
Expand Down Expand Up @@ -220,6 +233,8 @@
expect(chef_run).to install_package('libpq-dev')
expect(chef_run).to install_package('redis-server')
expect(chef_run).to install_package('monit')
expect(chef_run).to install_package('tzdata')
expect(chef_run).to install_package('libxml2-dev')
end

it 'installs required packages for rhel' do
Expand All @@ -229,6 +244,8 @@
expect(chef_run_rhel).to install_package('postgresql94-devel')
expect(chef_run_rhel).to install_package('redis')
expect(chef_run_rhel).to install_package('monit')
expect(chef_run_rhel).to install_package('tzdata')
expect(chef_run_rhel).to install_package('libxml2-devel')
end

it 'defines service which starts nginx' do
Expand Down Expand Up @@ -272,6 +289,7 @@

context 'debian' do
it 'installs required packages' do
expect(chef_run).to install_package('apache2')
expect(chef_run).to install_package('bzip2')
expect(chef_run).to install_package('git')
expect(chef_run).to install_package('gzip')
Expand Down

0 comments on commit 77f569c

Please sign in to comment.