Fix uwsgi related tests

This commit is contained in:
Marin Vintila 2015-05-08 18:00:35 +03:00
parent 66ee87b89e
commit a8cb664ef5
2 changed files with 17 additions and 16 deletions

View file

@ -310,8 +310,8 @@ define nginx::resource::location (
if ($vhost == undef) {
fail('Cannot create a location reference without attaching to a virtual host')
}
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef) and ($fastcgi == undef) and ($uwsgi == undef) and ($location_custom_cfg == undef)) {
fail('Cannot create a location reference without a www_root, proxy, location_alias, fastcgi, uwsgi, stub_status, or location_custom_cfg defined')
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef) and ($fastcgi == undef) and ($uwsgi == undef) and ($location_custom_cfg == undef) and ($internal == false)) {
fail('Cannot create a location reference without a www_root, proxy, location_alias, fastcgi, uwsgi, stub_status, internal, or location_custom_cfg defined')
}
if (($www_root != undef) and ($proxy != undef)) {
fail('Cannot define both directory and proxy in a virtual host')
@ -354,7 +354,7 @@ define nginx::resource::location (
}
}
if $uwsgi != undef and !defined(File[$uwsgi_params]) {
if $ensure == present and $uwsgi != undef and !defined(File[$uwsgi_params]) {
file { $uwsgi_params:
ensure => present,
mode => '0770',

View file

@ -523,7 +523,7 @@ describe 'nginx::resource::location' do
let :default_params do
{
:location => 'location',
:uwsgi => 'uwsgi_upstream',
:uwsgi => 'unix:/home/project/uwsgi.socket',
:vhost => 'vhost1'
}
end
@ -533,50 +533,51 @@ describe 'nginx::resource::location' do
:title => 'should set www_root',
:attr => 'www_root',
:value => '/',
:match => ' root /;'
:match => %r'\s+root\s+/;'
},
{
:title => 'should set try_file(s)',
:attr => 'try_files',
:value => ['name1','name2'],
:match => ' try_files name1 name2;',
:match => %r'\s+try_files\s+name1 name2;',
},
{
:title => 'should set uwsgi_params',
:attr => 'uwsgi_params',
:value => 'value',
:match => /^[ ]+include\s+value;/
:match => %r'\s+include\s+value;'
},
{
:title => 'should set uwsgi_pass',
:attr => 'uwsgi',
:value => 'value',
:match => ' uwsgi_pass value;'
:match => %r'\s+uwsgi_pass\s+value;'
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
let :params do default_params.merge({ param[:attr].to_sym => param[:value] }) end
it { should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it { is_expected.to contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")) }
it param[:title] do
fragment = Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")
matches = Array(param[:match])
if matches.all? { |m| m.is_a? Regexp }
matches.each { |item| should contain_concat__fragment(fragment).with_content(item) }
matches.each { |item| is_expected.to contain_concat__fragment(fragment).with_content(item) }
else
lines = subject.resource('concat::fragment', fragment).send(:parameters)[:content].split("\n")
(lines & matches).should == matches
lines = catalogue.resource('concat::fragment', fragment).send(:parameters)[:content].split("\n")
expect(lines & matches).to eq(matches)
end
Array(param[:notmatch]).each do |item|
should contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
is_expected.to contain_concat__fragment(Digest::MD5.hexdigest("vhost1-500-#{params[:location]}")).without_content(item)
end
end
end
end
end
describe "vhost_location_proxy template content" do
[
{
@ -700,10 +701,10 @@ describe 'nginx::resource::location' do
it { is_expected.to contain_file('/etc/nginx/fastcgi_params').with_mode('0770') }
end
context 'when uwsgi => "uwsgi_upstream"' do
let :params do { :fastcgi => 'uwsgi_upstream', :vhost => 'vhost1' } end
context 'when uwsgi => "unix:/home/project/uwsgi.socket"' do
let :params do { :uwsgi => 'uwsgi_upstream', :vhost => 'vhost1' } end
it { should contain_file('/etc/nginx/uwsgi_params').with_mode('0770') }
it { should contain_file('/etc/nginx/uwsgi_params') }
end