|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'datadog_agent::integrations::memcache' do |
| 4 | + let(:facts) {{ |
| 5 | + operatingsystem: 'Ubuntu', |
| 6 | + }} |
| 7 | + let(:conf_dir) { '/etc/dd-agent/conf.d' } |
| 8 | + let(:dd_user) { 'dd-agent' } |
| 9 | + let(:dd_group) { 'root' } |
| 10 | + let(:dd_package) { 'datadog-agent' } |
| 11 | + let(:dd_service) { 'datadog-agent' } |
| 12 | + let(:conf_file) { "#{conf_dir}/mcache.yaml" } |
| 13 | + |
| 14 | + it { should compile.with_all_deps } |
| 15 | + it { should contain_file(conf_file).with( |
| 16 | + owner: dd_user, |
| 17 | + group: dd_group, |
| 18 | + mode: '0600', |
| 19 | + )} |
| 20 | + it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") } |
| 21 | + it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") } |
| 22 | + |
| 23 | + context 'with default parameters' do |
| 24 | + it { should contain_file(conf_file).with_content(%r{url: localhost}) } |
| 25 | + it { should contain_file(conf_file).without_content(/tags:/) } |
| 26 | + end |
| 27 | + |
| 28 | + context 'with parameters set' do |
| 29 | + let(:params) {{ |
| 30 | + url: 'foobar', |
| 31 | + port: '11212', |
| 32 | + items: 'true', |
| 33 | + slabs: 'true', |
| 34 | + tags: %w{foo bar baz}, |
| 35 | + }} |
| 36 | + it { should contain_file(conf_file).with_content(%r{url: foobar}) } |
| 37 | + it { should contain_file(conf_file).with_content(/port: 11212/) } |
| 38 | + it { should contain_file(conf_file).with_content(/items: true/) } |
| 39 | + it { should contain_file(conf_file).with_content(/slabs: true/) } |
| 40 | + end |
| 41 | + |
| 42 | + context 'with tags parameter single value' do |
| 43 | + let(:params) {{ |
| 44 | + tags: 'foo', |
| 45 | + }} |
| 46 | + it { should_not compile } |
| 47 | + |
| 48 | + skip "this is currently unimplemented behavior" do |
| 49 | + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s*?[^-]/m) } |
| 50 | + end |
| 51 | + end |
| 52 | + |
| 53 | + context 'with tags parameter array' do |
| 54 | + let(:params) {{ |
| 55 | + tags: %w{ foo bar baz }, |
| 56 | + }} |
| 57 | + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) } |
| 58 | + end |
| 59 | + |
| 60 | + context 'with tags parameter empty values' do |
| 61 | + context 'mixed in with other tags' do |
| 62 | + let(:params) {{ |
| 63 | + tags: [ 'foo', '', 'baz' ] |
| 64 | + }} |
| 65 | + |
| 66 | + it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) } |
| 67 | + end |
| 68 | + |
| 69 | + context 'single element array of an empty string' do |
| 70 | + let(:params) {{ |
| 71 | + tags: [''], |
| 72 | + }} |
| 73 | + |
| 74 | + skip("undefined behavior") |
| 75 | + end |
| 76 | + |
| 77 | + context 'single value empty string' do |
| 78 | + let(:params) {{ |
| 79 | + tags: '', |
| 80 | + }} |
| 81 | + |
| 82 | + skip("doubly undefined behavior") |
| 83 | + end |
| 84 | + end |
| 85 | +end |
0 commit comments