Skip to content

Commit

Permalink
[http_check] fixing spec test for older puppets.
Browse files Browse the repository at this point in the history
  • Loading branch information
truthbk committed Apr 12, 2016
1 parent c34121d commit 5f19f8f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion manifests/integrations/http_check.pp
Expand Up @@ -90,7 +90,7 @@
) inherits datadog_agent::params {
include datadog_agent

if $instances == undef {
if !$instances and $url {
$_instances = [{
'url' => $url,
'username' => $username,
Expand All @@ -105,6 +105,8 @@
'tags' => $tags,
'contact' => $contact,
}]
} elsif !$instances{
$_instances = []
} else {
$_instances = $instances
}
Expand Down
12 changes: 8 additions & 4 deletions spec/classes/datadog_agent_integrations_http_check_spec.rb
Expand Up @@ -21,15 +21,15 @@
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }

context 'with default parameters' do
it { should contain_file(conf_file).with_content(%r{url: }) }
it { should contain_file(conf_file).without_content(%r{url: }) }
it { should contain_file(conf_file).without_content(%r{username: }) }
it { should contain_file(conf_file).without_content(%r{password: }) }
it { should contain_file(conf_file).with_content(%r{timeout: 1}) }
it { should contain_file(conf_file).without_content(%r{timeout: 1}) }
it { should contain_file(conf_file).without_content(%{threshold: }) }
it { should contain_file(conf_file).without_content(%r{window: }) }
it { should contain_file(conf_file).without_content(%r{include_content: true}) }
it { should contain_file(conf_file).with_content(%r{collect_response_time: true}) }
it { should contain_file(conf_file).with_content(%r{disable_ssl_validation: false}) }
it { should contain_file(conf_file).without_content(%r{collect_response_time: true}) }
it { should contain_file(conf_file).without_content(%r{disable_ssl_validation: false}) }
it { should contain_file(conf_file).without_content(%r{headers: }) }
it { should contain_file(conf_file).without_content(%r{tags: }) }
end
Expand Down Expand Up @@ -60,6 +60,7 @@

context 'with headers parameter array' do
let(:params) {{
url: 'http://foo.bar.baz:4096',
headers: %w{ foo bar baz },
}}
it { should contain_file(conf_file).with_content(/headers:\s+foo\s+bar\s+baz\s*?[^-]/m) }
Expand All @@ -68,6 +69,7 @@
context 'with headers parameter empty values' do
context 'mixed in with other headers' do
let(:params) {{
url: 'http://foo.bar.baz:4096',
headers: [ 'foo', '', 'baz' ]
}}

Expand All @@ -94,6 +96,7 @@

context 'with tags parameter array' do
let(:params) {{
url: 'http://foo.bar.baz:4096',
tags: %w{ foo bar baz },
}}
it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) }
Expand All @@ -102,6 +105,7 @@
context 'with tags parameter empty values' do
context 'mixed in with other tags' do
let(:params) {{
url: 'http://foo.bar.baz:4096',
tags: [ 'foo', '', 'baz' ]
}}

Expand Down

0 comments on commit 5f19f8f

Please sign in to comment.