Skip to content

Commit 425a6bf

Browse files
authored
Merge pull request #558 from DataDog/albertvaka/fix-double-end
Change unless -> not
2 parents b121b35 + 848f045 commit 425a6bf

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

spec/classes/datadog_agent_integrations_redis_spec.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,42 @@
137137
it { should contain_file(conf_file).without_content(%r{warn_on_missing_keys: false}) }
138138
it { should contain_file(conf_file).without_content(%r{command_stats: true}) }
139139
end
140+
141+
context 'with only keys' do
142+
let(:params) {{
143+
instances: [
144+
{
145+
'host' => 'redis1',
146+
'password' => 'hunter2',
147+
'port' => 2379,
148+
'tags' => %w(),
149+
'keys' => %w(baz bat),
150+
},
151+
],
152+
}}
153+
it { should contain_file(conf_file).with_content(%r{host: redis1}) }
154+
it { should contain_file(conf_file).with_content(%r{^[^#]*password: hunter2}) }
155+
it { should contain_file(conf_file).with_content(%r{port: 2379}) }
156+
it { should contain_file(conf_file).with_content(%r{keys:.*\s+- baz\s+- bat}) }
157+
end
158+
159+
context 'with only tags' do
160+
let(:params) {{
161+
instances: [
162+
{
163+
'host' => 'redis1',
164+
'password' => 'hunter2',
165+
'port' => 2379,
166+
'tags' => %w(baz bat),
167+
'keys' => %w(),
168+
},
169+
],
170+
}}
171+
it { should contain_file(conf_file).with_content(%r{host: redis1}) }
172+
it { should contain_file(conf_file).with_content(%r{^[^#]*password: hunter2}) }
173+
it { should contain_file(conf_file).with_content(%r{port: 2379}) }
174+
it { should contain_file(conf_file).with_content(%r{tags:.*\s+- baz\s+- bat}) }
175+
end
140176
end
141177
end
142178
end

templates/agent-conf.d/redisdb.yaml.erb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ instances:
1919
<% if !instance['command_stats'].nil? -%>
2020
command_stats: <%= instance['command_stats'] %>
2121
<% end -%>
22-
<% if instance['keys'] and unless instance['keys'].empty? -%>
22+
<% if instance['keys'] and ! instance['keys'].empty? -%>
2323
keys:
2424
<%- Array(instance['keys'] ).each do |key| -%>
2525
<%- if key != '' -%>
2626
- <%= key %>
2727
<%- end -%>
2828
<%- end -%>
2929
<% end -%>
30-
<% if instance['tags'] and unless instance['tags'].empty? -%>
30+
<% if instance['tags'] and ! instance['tags'].empty? -%>
3131
tags:
3232
<%- Array(instance['tags'] ).each do |tag| -%>
3333
<%- if tag != '' -%>
@@ -36,6 +36,3 @@ instances:
3636
<%- end -%>
3737
<% end -%>
3838
<% end -%>
39-
40-
<% end -%>
41-
<% end -%>

0 commit comments

Comments
 (0)