Skip to content

Commit

Permalink
[mongo] Add basic spec test (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
olivielpeau authored Sep 28, 2017
1 parent d6f16bd commit 8b80d23
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions spec/integrations/mongo_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
describe 'datadog::mongo' do
expected_yaml = <<-EOF
init_config:
instances:
- server: mongodb://localhost:27017
tags:
- 'env:test'
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',
mongo: {
instances: [
{
host: 'localhost',
port: '27017',
tags: ['env:test']
}
]
}
}
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('mongo') }

it 'renders expected YAML config file' do
expect(chef_run).to(render_file('/etc/dd-agent/conf.d/mongo.yaml').with_content { |content|
expect(YAML.safe_load(content).to_json).to be_json_eql(YAML.safe_load(expected_yaml).to_json)
})
end
end

0 comments on commit 8b80d23

Please sign in to comment.