-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from matonb/feature/refresh_pattern
Add refresh_pattern defined type
- Loading branch information
Showing
9 changed files
with
223 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
define squid::refresh_pattern ( | ||
Integer $max, | ||
Integer $min, | ||
Integer $percent, | ||
Boolean $case_sensitive = true, | ||
String $options = '', | ||
String $order = '05', | ||
String $pattern = $title, | ||
String $comment = "refresh_pattern fragment for ${pattern}", | ||
) { | ||
|
||
concat::fragment{"squid_refresh_pattern_${pattern}": | ||
target => $::squid::config, | ||
content => template('squid/squid.conf.refresh_pattern.erb'), | ||
order => "45-${order}", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
require 'spec_helper' | ||
|
||
describe 'squid::refresh_pattern' do | ||
on_supported_os.each do |os, facts| | ||
context "on #{os}" do | ||
let(:facts) do | ||
facts | ||
end | ||
let :pre_condition do | ||
' class{"::squid": | ||
config => "/tmp/squid.conf" | ||
} | ||
' | ||
end | ||
|
||
context 'when parameters are set' do | ||
let(:title) { 'my_pattern' } | ||
let(:params) do | ||
{ | ||
order: '06', | ||
max: 10_080, | ||
min: 1440, | ||
percent: 20, | ||
comment: 'Refresh Patterns' | ||
} | ||
end | ||
|
||
fname = 'squid_refresh_pattern_my_pattern' | ||
it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') } | ||
it { is_expected.to contain_concat_fragment(fname).with_order('45-06') } | ||
it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+my_pattern:\s+1440\s+20%\s+10080$}) } | ||
end # context 'when parameters are set' | ||
|
||
context 'when parameters are set and case insensitive' do | ||
let(:title) { 'case_insensitive' } | ||
let(:params) do | ||
{ | ||
case_sensitive: false, | ||
comment: 'Refresh Patterns', | ||
max: 0, | ||
min: 0, | ||
order: '07', | ||
percent: 0 | ||
} | ||
end | ||
|
||
fname = 'squid_refresh_pattern_case_insensitive' | ||
it { is_expected.to contain_concat_fragment(fname).with_target('/tmp/squid.conf') } | ||
it { is_expected.to contain_concat_fragment(fname).with_order('45-07') } | ||
it { is_expected.to contain_concat_fragment(fname).with_content(%r{^refresh_pattern\s+case_insensitive:\s+-i\s+0\s+0%\s+0$}) } | ||
end # context 'when parameters are set and case insensitive' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# <%= @comment %> | ||
refresh_pattern <%= @pattern %>: <%= @case_sensitive?'':'-i ' %><%= @min %> <%= @percent %>% <%= @max %><%= @options ? @options:'' %> |