From bff27b5d8c34319c5c4028f4a5a81535f448e8bc Mon Sep 17 00:00:00 2001
From: Jonathan Pastor <jonathancmoa@gmail.com>
Date: Thu, 7 Nov 2019 15:12:48 +0100
Subject: [PATCH] implement a spec test for generator expecting no value

---
 spec/oar_properties_spec.rb | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/spec/oar_properties_spec.rb b/spec/oar_properties_spec.rb
index 3903dee528..77416a4b23 100644
--- a/spec/oar_properties_spec.rb
+++ b/spec/oar_properties_spec.rb
@@ -2110,6 +2110,42 @@ GeForce RTX 2080 Ti
       expect(generator_output[:stdout]).to include(expected_output)
       expect(generator_output[:stdout]).not_to include(not_expected_output)
     end
+
+    it 'should ignore the GPUs' do
+
+      uri = URI(conf["uri"])
+
+      response = Net::HTTP.get(uri)
+
+      expect(response).to be_an_instance_of(String)
+
+      options = {
+        :table => false,
+        :print => false,
+        :update => false,
+        :diff => true,
+        :site => "fakesite",
+        :clusters => ["clustera"],
+        :verbose => 2
+      }
+
+      expected_output = <<-TXT
+# Error: Resource 1 (host=clustera-1.fakesite.grid5000.fr cpu=1 core=1 cpuset=0 gpu=1 gpudevice=0) has a mismatch for ressource GPU: OAR API gives 1, generator wants ø.
+# Error: Resource 1 (host=clustera-1.fakesite.grid5000.fr cpu=1 core=1 cpuset=0 gpu=1 gpudevice=0) has a mismatch for ressource GPUDEVICE: OAR API gives 0, generator wants ø.
+# Error: Resource 2 (host=clustera-1.fakesite.grid5000.fr cpu=1 core=2 cpuset=1 gpu=1 gpudevice=0) has a mismatch for ressource GPU: OAR API gives 1, generator wants ø.
+      TXT
+
+      not_expected_output = <<-TXT
+GeForce RTX 2080 Ti
+      TXT
+
+      generator_output = capture do
+        generate_oar_properties(options)
+      end
+
+      expect(generator_output[:stdout]).to include(expected_output)
+      expect(generator_output[:stdout]).not_to include(not_expected_output)
+    end
   end
 
 end
-- 
GitLab