From b9a98f3e106dd5d4ca3c12177a375bd69d81e9cc Mon Sep 17 00:00:00 2001 From: Helen Griffiths <16269977+threepistons@users.noreply.github.com> Date: Tue, 6 Jul 2021 16:51:11 +0100 Subject: [PATCH] Teams often insists that you use the latest client and offers updates so I do that in the module to stop the users from seeing the messages. Wrong OS should fail. --- manifests/init.pp | 6 +++--- spec/classes/teams_spec.rb | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 54998bc..3b52ee5 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -22,18 +22,18 @@ } ~> package { 'teams': - ensure => installed, + ensure => latest, require => Apt::Source['teams'], } } default: { - notify { 'Unsupported architecture': } + fail('Teams only runs on AMD64, your architecture is unsupported.') } } } default: { - notify { 'Unsupported OS': } + fail('The Teams installer module only works with Debian derivatives, your distribution is unsupported.') } } } diff --git a/spec/classes/teams_spec.rb b/spec/classes/teams_spec.rb index 4fd26de..c59881e 100644 --- a/spec/classes/teams_spec.rb +++ b/spec/classes/teams_spec.rb @@ -24,4 +24,26 @@ it { is_expected.to contain_package('teams').with('require' => 'Apt::Source[teams]') } end end + context 'should fail on Pis' do + let(:facts) do + { + 'os' => { + 'architecture' => 'armv7l', + }, + } + end + + it { is_expected.not_to compile } # this is how to test for the 'fail' built-in function because 'fail' results in a compilation error + end # end of the Pi context + context 'should fail on RedHat-like OSes' do + let(:facts) do + { + 'os' => { + 'operatingsystem' => 'CentOS', + }, + } + end + + it { is_expected.not_to compile } # this is how to test for the 'fail' built-in function because 'fail' results in a compilation error + end # end of the Pi context end