-
Notifications
You must be signed in to change notification settings - Fork 262
/
postgres_spec.rb
57 lines (50 loc) · 1.43 KB
/
postgres_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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