From d7f6d91a11d73d2200df38f5be59782f8dff5988 Mon Sep 17 00:00:00 2001 From: Max Wilhelm Date: Mon, 14 Aug 2017 17:56:20 +0200 Subject: [PATCH] use rspec-puppet-facts for fluentd_repo_apt_spec --- spec/classes/fluentd_repo_apt_spec.rb | 101 +++++++++++++++++++------- 1 file changed, 74 insertions(+), 27 deletions(-) diff --git a/spec/classes/fluentd_repo_apt_spec.rb b/spec/classes/fluentd_repo_apt_spec.rb index ce6bc15..94224c4 100644 --- a/spec/classes/fluentd_repo_apt_spec.rb +++ b/spec/classes/fluentd_repo_apt_spec.rb @@ -1,34 +1,81 @@ require 'spec_helper' describe 'fluentd::repo::apt', :type => :class do - let(:facts) { - { - :osfamily => 'Debian', - :lsbdistid => 'Ubuntu', - :operatingsystem => 'Ubuntu', - :lsbdistcodename => 'precise', - :architecture => 'amd64', - } - } + on_supported_os.each do |os, facts| + context "on #{os}" do + let :facts do + facts + end - describe 'when called with no parameters on Ubuntu' do - it { - should contain_class('apt') - should contain_apt__source('treasure-data').with({ - 'ensure' => 'present', - 'location' => 'http://packages.treasuredata.com/2/ubuntu/precise', - 'release' => 'precise', - 'repos' => 'contrib', - 'architecture' => 'amd64', - 'key' => { - 'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE', - 'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent' - }, - 'include' => { - 'src' => false, - 'deb' => true + case facts[:osfamily] + when 'Debian' + it { + should contain_class('apt') + should contain_apt__source('treasure-data').with({ + 'ensure' => 'present', + 'repos' => 'contrib', + 'architecture' => 'amd64', + 'key' => { + 'id' => 'BEE682289B2217F45AF4CC3F901F9177AB97ACBE', + 'source' => 'http://packages.treasuredata.com/GPG-KEY-td-agent' + }, + 'include' => { + 'src' => false, + 'deb' => true + } + }) } - }) - } + case facts[:operatingsystem] + when 'Ubuntu' + case facts[:lsbdistcodename] + when 'precise' + it { + should contain_apt__source('treasure-data').with({ + 'location' => 'http://packages.treasuredata.com/2/ubuntu/precise', + 'release' => 'precise' + }) + } + when 'trusty' + it { + should contain_apt__source('treasure-data').with({ + 'location' => 'http://packages.treasuredata.com/2/ubuntu/trusty', + 'release' => 'trusty' + }) + } + when 'xenial' + it { + should contain_apt__source('treasure-data').with({ + 'location' => 'http://packages.treasuredata.com/2/ubuntu/xenial', + 'release' => 'xenial' + }) + } + end + when 'Debian' + case facts[:lsbdistcodename] + when 'jessie' + it { + should contain_apt__source('treasure-data').with({ + 'location' => 'http://packages.treasuredata.com/2/debian/jessie', + 'release' => 'jessie' + }) + } + when 'squeeze' + it { + should contain_apt__source('treasure-data').with({ + 'location' => 'http://packages.treasuredata.com/2/debian/squeeze', + 'release' => 'squeeze' + }) + } + when 'wheezy' + it { + should contain_apt__source('treasure-data').with({ + 'location' => 'http://packages.treasuredata.com/2/debian/wheezy', + 'release' => 'wheezy' + }) + } + end + end + end + end end end