From 5f213da8b3d260558c1a0d965ed0417f55a741c7 Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Thu, 17 Aug 2017 13:33:54 +0200 Subject: [PATCH] use rspec-puppet-facts for match_spec --- spec/defines/match_spec.rb | 119 ++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/spec/defines/match_spec.rb b/spec/defines/match_spec.rb index c2da497..53e1806 100644 --- a/spec/defines/match_spec.rb +++ b/spec/defines/match_spec.rb @@ -1,72 +1,71 @@ require 'spec_helper' describe 'fluentd::match' do - let(:facts) { - { - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :operatingsystem => 'Ubuntu', - :lsbdistcodename => 'precise', - :architecture => 'amd64', - } - } - let(:pre_condition) { 'include fluentd' } + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts + end - context 'basic match' do - let(:title) { 'test' } - let(:params) do - { - priority: '30', - pattern: '*.test', - config: { - 'flush_interval' => '30s', - 'type' => 'secure_forward', - 'secure' => 'yes', - 'shared_key' => 'my_shared_key', - 'self_hostname' => 'instance.test.com', - 'ca_cert_path' => '/path/to/ca.cert', - 'server' => [ - { - 'host' => 'test.server.com', - } - ] + let(:pre_condition) { 'include fluentd' } + + describe 'basic match' do + let(:title) { 'test' } + let(:params) do + { + priority: '30', + pattern: '*.test', + config: { + 'flush_interval' => '30s', + 'type' => 'secure_forward', + 'secure' => 'yes', + 'shared_key' => 'my_shared_key', + 'self_hostname' => 'instance.test.com', + 'ca_cert_path' => '/path/to/ca.cert', + 'server' => [ + { + 'host' => 'test.server.com', + } + ] + } } - } - end + end - it do - is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf'). - with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_secure_forward.conf'))) - end - end + it do + is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf'). + with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_secure_forward.conf'))) + end + end - context 'multiple store' do - let(:title) { 'test' } - let(:params) do - { - priority: '30', - pattern: '*.test', - config: { - 'type' => 'copy', - 'store' => [ - { - 'type' => 'elasticsearch', - 'logstashformat' => true, - 'hosts' => '172.20.10.17:9200', - 'flush_interval' => '30s', - }, - { - 'type' => 'file', - 'path' => '/tmp/td-agent-debug.log', - } - ] + describe 'multiple store' do + let(:title) { 'test' } + let(:params) do + { + priority: '30', + pattern: '*.test', + config: { + 'type' => 'copy', + 'store' => [ + { + 'type' => 'elasticsearch', + 'logstashformat' => true, + 'hosts' => '172.20.10.17:9200', + 'flush_interval' => '30s', + }, + { + 'type' => 'file', + 'path' => '/tmp/td-agent-debug.log', + } + ] + } } - } - end + end - it do - is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf'). - with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_copy.conf'))) + it do + is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf'). + with_content(IO.read(File.join(File.dirname(__FILE__), '../fixtures/files/match_copy.conf'))) + end + end end end end