Skip to content

Commit 91d351e

Browse files
committed
Expect current default for gunicorn workers
Given that legacy facts were removed from facterdb 3, the current behavior relies on `NilClass#to_i` resolving to missing fact to 0. The added test case for custom `workers` parameter given cannot give false positives with the default formula always being an odd number.
1 parent 459e30e commit 91d351e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

spec/defines/gunicorn_spec.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@
1212
describe 'test-app with default parameter values' do
1313
context 'configures test app with default parameter values' do
1414
let(:params) { { dir: '/srv/testapp' } }
15+
let(:expected_workers) do
16+
# templates/gunicorn.erb
17+
(facts[:processorcount].to_i * 2) + 1
18+
end
1519

1620
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--log-level=error}) }
21+
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--workers=#{expected_workers}}) }
1722
end
1823

1924
context 'test-app with custom log level' do
@@ -27,6 +32,12 @@
2732

2833
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--preload}) }
2934
end
35+
36+
context 'test-app with custom workers count' do
37+
let(:params) { { dir: '/srv/testapp', workers: 42 } }
38+
39+
it { is_expected.to contain_file('/etc/gunicorn.d/test-app').with_mode('0644').with_content(%r{--workers=#{params[:workers]}}) }
40+
end
3041
end
3142
end
3243
end

0 commit comments

Comments
 (0)