-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix postgres template syntax and parameter output (#304)
- Use correct `.key?` syntax, Fix #300 - Emit correct boolean, introduced in #278 - Add postgres spec test Closes #302 Signed-off-by: Mike Fiedler <miketheman@gmail.com>
- Loading branch information
1 parent
b8cb6dc
commit d6eb9d9
Showing
2 changed files
with
59 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
describe 'datadog::postgres' do | ||
expected_yaml = <<-EOF | ||
instances: | ||
- host: localhost | ||
port: 5432 | ||
ssl: true | ||
username: datadog | ||
password: somepass | ||
dbname: my_database | ||
tags: | ||
- spec | ||
relations: | ||
- apple_table | ||
- orange_table | ||
collect_function_metrics: true | ||
init_config: | ||
EOF | ||
|
||
cached(:chef_run) do | ||
ChefSpec::SoloRunner.new(step_into: ['datadog_monitor']) do |node| | ||
node.automatic['languages'] = { python: { version: '2.7.2' } } | ||
|
||
node.set['datadog'] = { | ||
api_key: 'someapikey', | ||
postgres: { | ||
instances: [ | ||
{ | ||
collect_function_metrics: true, | ||
dbname: 'my_database', | ||
password: 'somepass', | ||
port: 5432, | ||
relations: ['apple_table', 'orange_table'], | ||
server: 'localhost', | ||
ssl: true, | ||
tags: ['spec'], | ||
username: 'datadog' | ||
} | ||
] | ||
} | ||
} | ||
end.converge(described_recipe) | ||
end | ||
|
||
subject { chef_run } | ||
|
||
it_behaves_like 'datadog-agent' | ||
|
||
it { is_expected.to include_recipe('datadog::dd-agent') } | ||
|
||
it { is_expected.to add_datadog_monitor('postgres') } | ||
|
||
it 'renders expected YAML config file' do | ||
expect(chef_run).to render_file('/etc/dd-agent/conf.d/postgres.yaml').with_content { |content| | ||
expect(YAML.load(content).to_json).to be_json_eql(YAML.load(expected_yaml).to_json) | ||
} | ||
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