diff --git a/spec/classes/agent_spec.rb b/spec/classes/agent_spec.rb index c52280fc..65e9003e 100644 --- a/spec/classes/agent_spec.rb +++ b/spec/classes/agent_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +include Puppet::Util describe 'zabbix::agent' do let :node do @@ -68,8 +69,16 @@ it { is_expected.to contain_selinux__module('zabbix-agent') } if facts[:os]['family'] == 'RedHat' it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) - it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' - it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' + case facts[:os]['name'] + when 'Debian' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '12') >= 0 + when 'Ubuntu' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0 + end it { is_expected.to contain_file(include_dir).with_ensure('directory') } # Make sure package will be installed, service running and ensure of directory. diff --git a/spec/classes/javagateway_spec.rb b/spec/classes/javagateway_spec.rb index 5350a82c..c1a22419 100644 --- a/spec/classes/javagateway_spec.rb +++ b/spec/classes/javagateway_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +include Puppet::Util describe 'zabbix::javagateway' do let :node do @@ -29,8 +30,16 @@ it { is_expected.to contain_yumrepo('zabbix-frontend') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['family'] == 'RedHat' && facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) - it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' - it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' + case facts[:os]['name'] + when 'Debian' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '12') >= 0 + when 'Ubuntu' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0 + end end context 'when declaring manage_repo is true' do diff --git a/spec/classes/repo_spec.rb b/spec/classes/repo_spec.rb index 1ff31bf8..7e3d0e1c 100644 --- a/spec/classes/repo_spec.rb +++ b/spec/classes/repo_spec.rb @@ -2,6 +2,7 @@ require 'deep_merge' require 'spec_helper' +include Puppet::Util describe 'zabbix::repo' do on_supported_os.each do |os, facts| @@ -19,9 +20,16 @@ it { is_expected.to compile.with_all_deps } it { is_expected.to contain_class('zabbix::params') } it { is_expected.to contain_class('zabbix::repo') } - - it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' - it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' + case facts[:os]['name'] + when 'Debian' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '12') >= 0 + when 'Ubuntu' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0 + end context 'when repo_location is "https://example.com/foo"' do let :params do diff --git a/spec/classes/sender_spec.rb b/spec/classes/sender_spec.rb index 47f96393..8c1bed9c 100644 --- a/spec/classes/sender_spec.rb +++ b/spec/classes/sender_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'spec_helper' +include Puppet::Util describe 'zabbix::sender' do let :node do @@ -53,8 +54,16 @@ it { is_expected.to contain_package('zabbix-required-scl-repo') } if facts[:os]['release']['major'] == '7' && %w[OracleLinux CentOS].include?(facts[:os]['name']) when 'Debian' it { is_expected.to contain_apt__source('zabbix') } - it { is_expected.to contain_apt__key('zabbix-A1848F5') } - it { is_expected.to contain_apt__key('zabbix-FBABD5F') } + case facts[:os]['name'] + when 'Debian' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '12') >= 0 + when 'Ubuntu' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0 + end end end end diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 910819ef..27b799e6 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'deep_merge' +include Puppet::Util describe 'zabbix::server' do let :node do @@ -28,8 +29,16 @@ it { is_expected.not_to contain_zabbix__startup('zabbix-server') } it { is_expected.to contain_apt__source('zabbix') } if facts[:os]['family'] == 'Debian' - it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' - it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' + case facts[:os]['name'] + when 'Debian' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '12') >= 0 + when 'Ubuntu' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0 + end end if facts[:os]['family'] == 'RedHat' diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb index 5864765e..0f812c0e 100644 --- a/spec/classes/web_spec.rb +++ b/spec/classes/web_spec.rb @@ -2,6 +2,7 @@ require 'spec_helper' require 'deep_merge' +include Puppet::Util describe 'zabbix::web' do let :node do @@ -40,8 +41,16 @@ class { 'apache': it { is_expected.to contain_class('Zabbix::Repo') } it { is_expected.to contain_file('/etc/zabbix/web').with_ensure('directory') } - it { is_expected.to contain_apt__key('zabbix-A1848F5') } if facts[:os]['family'] == 'Debian' - it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if facts[:os]['family'] == 'Debian' + case facts[:os]['name'] + when 'Debian' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '12') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '12') >= 0 + when 'Ubuntu' + it { is_expected.to contain_apt__key('zabbix-A1848F5') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__key('zabbix-FBABD5F') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') < 0 + it { is_expected.to contain_apt__keyring('zabbix-official-repo.asc') } if Package.versioncmp(facts[:os]['release']['major'], '22.04') >= 0 + end it { is_expected.to contain_apt__source('zabbix') } if facts[:os]['family'] == 'Debian' it { is_expected.to contain_yumrepo('zabbix') } if facts[:os]['family'] == 'RedHat' it { is_expected.to contain_yumrepo('zabbix-nonsupported') } if facts[:os]['family'] == 'RedHat'