From b2b1fee370060c82101526157dc2630a4453dfb8 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Sun, 31 May 2020 22:59:26 +0100 Subject: [PATCH] test(pkgs_spec): simplify using `match` (trigger: update for `suse`) * https://travis-ci.org/github/myii/salt-formula/jobs/692337807#L2366-L2381 - `opensuse` now has `3000.3` available * Simplification is useful anyway, even without this (could still use `case`) --- .../v201902-py2/controls/pkgs_spec.rb | 24 ++------------ .../v201902-py3/controls/pkgs_spec.rb | 22 ++----------- .../v3000-py2/controls/pkgs_spec.rb | 10 ++---- .../v3000-py3/controls/pkgs_spec.rb | 32 ++----------------- 4 files changed, 12 insertions(+), 76 deletions(-) diff --git a/test/integration/v201902-py2/controls/pkgs_spec.rb b/test/integration/v201902-py2/controls/pkgs_spec.rb index 0ce81c0..d35fe1c 100644 --- a/test/integration/v201902-py2/controls/pkgs_spec.rb +++ b/test/integration/v201902-py2/controls/pkgs_spec.rb @@ -1,35 +1,17 @@ # frozen_string_literal: true -# Prepare platform "finger" -platform_finger = "#{platform[:name]}-#{platform[:release].split('.')[0]}" - -version = - case platform[:family] - when 'debian' - '2019.2.5+ds-1' - when 'redhat' - case platform_finger - when 'centos-7' - '2019.2.5-1.el7' - when 'centos-6' - '2019.2.5-1.el6' - when 'amazon-2' - '2019.2.5-1.amzn2' - when 'amazon-2018' - '2019.2.5-1.amzn1' - end - end - control 'salt packages' do title 'should be installed' + version = '2019.2.5' + %w[ salt-master salt-minion ].each do |p| describe package(p) do it { should be_installed } - its('version') { should eq version } + its('version') { should match(/^#{version}/) } end end end diff --git a/test/integration/v201902-py3/controls/pkgs_spec.rb b/test/integration/v201902-py3/controls/pkgs_spec.rb index 74a5762..d35fe1c 100644 --- a/test/integration/v201902-py3/controls/pkgs_spec.rb +++ b/test/integration/v201902-py3/controls/pkgs_spec.rb @@ -1,33 +1,17 @@ # frozen_string_literal: true -# Prepare platform "finger" -platform_finger = "#{platform[:name]}-#{platform[:release].split('.')[0]}" - -version = - case platform[:family] - when 'debian' - '2019.2.5+ds-1' - when 'redhat' - case platform_finger - when 'centos-8' - '2019.2.5-1.el8' - when 'centos-7' - '2019.2.5-1.el7' - when 'amazon-2' - '2019.2.5-1.amzn2' - end - end - control 'salt packages' do title 'should be installed' + version = '2019.2.5' + %w[ salt-master salt-minion ].each do |p| describe package(p) do it { should be_installed } - its('version') { should eq version } + its('version') { should match(/^#{version}/) } end end end diff --git a/test/integration/v3000-py2/controls/pkgs_spec.rb b/test/integration/v3000-py2/controls/pkgs_spec.rb index d1f2d8c..d583f13 100644 --- a/test/integration/v3000-py2/controls/pkgs_spec.rb +++ b/test/integration/v3000-py2/controls/pkgs_spec.rb @@ -1,21 +1,17 @@ # frozen_string_literal: true -version = - case platform[:family] - when 'debian' - '3000.3+ds-1' - end - control 'salt packages' do title 'should be installed' + version = '3000.3' + %w[ salt-master salt-minion ].each do |p| describe package(p) do it { should be_installed } - its('version') { should eq version } + its('version') { should match(/^#{version}/) } end end end diff --git a/test/integration/v3000-py3/controls/pkgs_spec.rb b/test/integration/v3000-py3/controls/pkgs_spec.rb index ef30eaa..d583f13 100644 --- a/test/integration/v3000-py3/controls/pkgs_spec.rb +++ b/test/integration/v3000-py3/controls/pkgs_spec.rb @@ -1,43 +1,17 @@ # frozen_string_literal: true -# Prepare platform "finger" -platform_finger = "#{platform[:name]}-#{platform[:release].split('.')[0]}" - -version = - case platform[:family] - when 'debian' - '3000.3+ds-1' - when 'redhat' - case platform_finger - when 'centos-8' - '3000.3-1.el8' - when 'centos-7' - '3000.3-1.el7' - when 'amazon-2' - '3000.3-1.amzn2' - end - when 'fedora' - '3000.3-1.fc31' - when 'suse' - # Issue in the upstream repo, should be `3000.3` - case platform[:release] - when /^15.2/ - '3000.2-lp152.7.1' - when /^15.1/ - '3000.2-lp151.2.1' - end - end - control 'salt packages' do title 'should be installed' + version = '3000.3' + %w[ salt-master salt-minion ].each do |p| describe package(p) do it { should be_installed } - its('version') { should eq version } + its('version') { should match(/^#{version}/) } end end end