Faidon Liambotis has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405387 )

Change subject: wmflib: make os_version spec more extensive
......................................................................

wmflib: make os_version spec more extensive

Cover cases such as:
- no operator ('Debian jessie')
- compound expressions ('Debian jessie || Ubuntu trusty')
- testing against another operating system ('debian jessie' on a trusty)
- case sensitivity ('debian jessie')

Bug: T185345
Change-Id: I7aa053dea60614b36f5743cc26abd3e155390a0f
---
M modules/wmflib/spec/functions/os_version_spec.rb
1 file changed, 75 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/87/405387/1

diff --git a/modules/wmflib/spec/functions/os_version_spec.rb 
b/modules/wmflib/spec/functions/os_version_spec.rb
index f422356..4381f44 100644
--- a/modules/wmflib/spec/functions/os_version_spec.rb
+++ b/modules/wmflib/spec/functions/os_version_spec.rb
@@ -11,7 +11,7 @@
     end
   end
 
-  context 'when running on Ubuntu Trusty 14.04' do
+  context 'when running on Ubuntu Trusty Tahr (14.04)' do
     let(:facts) do
       {
         :lsbdistrelease => '14.04',
@@ -19,16 +19,56 @@
       }
     end
 
-    it 'matches properly' do
+    it 'matches comparing current release' do
+      expect(subject).to run.with_params('Ubuntu trusty').and_return(true)
       expect(subject).to run.with_params('Ubuntu == trusty').and_return(true)
       expect(subject).to run.with_params('Ubuntu >= trusty').and_return(true)
       expect(subject).to run.with_params('Ubuntu <= trusty').and_return(true)
       expect(subject).to run.with_params('Ubuntu > trusty').and_return(false)
       expect(subject).to run.with_params('Ubuntu < trusty').and_return(false)
     end
+
+    it 'matches comparing with next release' do
+      expect(subject).to run.with_params('Ubuntu utopic').and_return(false)
+      expect(subject).to run.with_params('Ubuntu == utopic').and_return(false)
+      expect(subject).to run.with_params('Ubuntu >= utopic').and_return(false)
+      expect(subject).to run.with_params('Ubuntu <= utopic').and_return(true)
+      expect(subject).to run.with_params('Ubuntu > utopic').and_return(false)
+      expect(subject).to run.with_params('Ubuntu < utopic').and_return(true)
+    end
+
+    it 'does not match with another operating system' do
+      expect(subject).to run.with_params('Debian jessie').and_return(false)
+      expect(subject).to run.with_params('Debian == jessie').and_return(false)
+      expect(subject).to run.with_params('Debian >= jessie').and_return(false)
+      expect(subject).to run.with_params('Debian <= jessie').and_return(false)
+      expect(subject).to run.with_params('Debian > jessie').and_return(false)
+      expect(subject).to run.with_params('Debian < jessie').and_return(false)
+    end
+
+    it 'works with compound expressions' do
+      expect(subject).to run.with_params('Ubuntu trusty || Debian 
jessie').and_return(true)
+      expect(subject).to run.with_params('Debian jessie || Ubuntu 
trusty').and_return(true)
+      expect(subject).to run.with_params('Ubuntu trusty || Ubuntu 
utopic').and_return(true)
+      expect(subject).to run.with_params('Ubuntu utopic || Ubuntu 
trusty').and_return(true)
+
+      expect(subject).to run.with_params('Ubuntu trusty || Ubuntu utopic || 
Debian jessie').and_return(true)
+      expect(subject).to run.with_params('Ubuntu utopic || Ubuntu xenial || 
Debian stretch').and_return(false)
+
+      expect(subject).to run.with_params('Ubuntu utopic || Debian 
jessie').and_return(false)
+      expect(subject).to run.with_params('Debian jessie || Ubuntu 
utopic').and_return(false)
+
+      expect(subject).to run.with_params('Debian jessie || Debian 
stretch').and_return(false)
+      expect(subject).to run.with_params('Debian stretch || Debian 
buster').and_return(false)
+    end
+
+    it 'is case insensitive' do
+      expect(subject).to run.with_params('ubuntu trusty').and_return(true)
+      expect(subject).to run.with_params('debian jessie').and_return(false)
+    end
   end
 
-  context 'when running on Debian Jessie 8' do
+  context 'when running on Debian 8 "jessie"' do
     let(:facts) do
       {
         :lsbdistrelease => '8.7',
@@ -37,6 +77,7 @@
     end
 
     it 'matches comparing current release' do
+      expect(subject).to run.with_params('Debian jessie').and_return(true)
       expect(subject).to run.with_params('Debian == jessie').and_return(true)
       expect(subject).to run.with_params('Debian >= jessie').and_return(true)
       expect(subject).to run.with_params('Debian <= jessie').and_return(true)
@@ -45,11 +86,42 @@
     end
 
     it 'matches comparing with next release' do
+      expect(subject).to run.with_params('Debian stretch').and_return(false)
       expect(subject).to run.with_params('Debian == stretch').and_return(false)
       expect(subject).to run.with_params('Debian >= stretch').and_return(false)
       expect(subject).to run.with_params('Debian <= stretch').and_return(true)
       expect(subject).to run.with_params('Debian > stretch').and_return(false)
       expect(subject).to run.with_params('Debian < stretch').and_return(true)
     end
+
+    it 'does not match with another operating system' do
+      expect(subject).to run.with_params('Ubuntu trusty').and_return(false)
+      expect(subject).to run.with_params('Ubuntu == trusty').and_return(false)
+      expect(subject).to run.with_params('Ubuntu >= trusty').and_return(false)
+      expect(subject).to run.with_params('Ubuntu <= trusty').and_return(false)
+      expect(subject).to run.with_params('Ubuntu > trusty').and_return(false)
+      expect(subject).to run.with_params('Ubuntu < trusty').and_return(false)
+    end
+
+    it 'works with compound expressions' do
+      expect(subject).to run.with_params('Ubuntu trusty || Debian 
jessie').and_return(true)
+      expect(subject).to run.with_params('Debian jessie || Ubuntu 
trusty').and_return(true)
+      expect(subject).to run.with_params('Ubuntu trusty || Ubuntu 
utopic').and_return(false)
+      expect(subject).to run.with_params('Ubuntu utopic || Ubuntu 
trusty').and_return(false)
+
+      expect(subject).to run.with_params('Ubuntu trusty || Ubuntu utopic || 
Debian jessie').and_return(true)
+      expect(subject).to run.with_params('Ubuntu utopic || Ubuntu xenial || 
Debian stretch').and_return(false)
+
+      expect(subject).to run.with_params('Ubuntu utopic || Debian 
jessie').and_return(true)
+      expect(subject).to run.with_params('Debian jessie || Ubuntu 
utopic').and_return(true)
+
+      expect(subject).to run.with_params('Debian jessie || Debian 
stretch').and_return(true)
+      expect(subject).to run.with_params('Debian stretch || Debian 
buster').and_return(false)
+    end
+
+    it 'is case insensitive' do
+      expect(subject).to run.with_params('ubuntu trusty').and_return(false)
+      expect(subject).to run.with_params('debian jessie').and_return(true)
+    end
   end
 end

-- 
To view, visit https://gerrit.wikimedia.org/r/405387
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7aa053dea60614b36f5743cc26abd3e155390a0f
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Faidon Liambotis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to