Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix trying to call .empty? on an integer #527

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions spec/classes/datadog_agent_integrations_redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
host: 'redis1',
password: 'hunter2',
port: 867,
slowlog_max_len: '5309',
slowlog_max_len: 5309,
tags: %w{foo bar},
keys: %w{baz bat},
warn_on_missing_keys: false,
Expand All @@ -69,7 +69,7 @@
host: 'redis1',
password: 'hunter2',
ports: %w(2379 2380 2381),
slowlog_max_len: '5309',
slowlog_max_len: 5309,
tags: %w{foo bar},
keys: %w{baz bat},
warn_on_missing_keys: false,
Expand All @@ -87,6 +87,27 @@
it { should contain_file(conf_file).with_content(%r{port: 2381}) }
end

context 'with strings instead of ints' do
let(:params) {{
host: 'redis1',
password: 'hunter2',
port: '867',
slowlog_max_len: '5309',
tags: %w{foo bar},
keys: %w{baz bat},
warn_on_missing_keys: false,
command_stats: true,
}}
it { should contain_file(conf_file).with_content(%r{host: redis1}) }
it { should contain_file(conf_file).with_content(%r{^[^#]*password: hunter2}) }
it { should contain_file(conf_file).with_content(%r{port: 867}) }
it { should contain_file(conf_file).with_content(%r{^[^#]*slowlog-max-len: 5309}) }
it { should contain_file(conf_file).with_content(%r{tags:.*\s+- foo\s+- bar}) }
it { should contain_file(conf_file).with_content(%r{keys:.*\s+- baz\s+- bat}) }
it { should contain_file(conf_file).with_content(%r{warn_on_missing_keys: false}) }
it { should contain_file(conf_file).with_content(%r{command_stats: true}) }
end

context 'with instances set' do
let(:params) {{
instances: [
Expand Down
2 changes: 1 addition & 1 deletion templates/agent-conf.d/redisdb.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ instances:
<% if instance['password'] and ! instance['password'].empty? -%>
password: <%= instance['password'] %>
<% end -%>
<% if instance['slowlog_max_len'] and ! instance['slowlog_max_len'].empty? -%>
<% if instance['slowlog_max_len'] and ! instance['slowlog_max_len'].to_s.empty? -%>
# unix_socket_path: /var/run/redis/redis.sock # optional, can be used in lieu of host/port
slowlog-max-len: <%= instance['slowlog_max_len'] %>
<% end -%>
Expand Down