[ARVADOS] updated: b6a922bd21b2c9da8861de4c84c2a2ab25666ef2

Git user git at public.curoverse.com
Mon Aug 1 17:31:27 EDT 2016


Summary of changes:
 services/api/test/unit/container_request_test.rb | 61 ++++++++----------------
 1 file changed, 20 insertions(+), 41 deletions(-)

       via  b6a922bd21b2c9da8861de4c84c2a2ab25666ef2 (commit)
      from  97c669426fd4a086883d1cf666043af17f99f758 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b6a922bd21b2c9da8861de4c84c2a2ab25666ef2
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Mon Aug 1 18:30:16 2016 -0300

    9617: Corrected style following suggestions and also compacted the code to avoid repetition.

diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 2096170..648b92d 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -56,55 +56,34 @@ class ContainerRequestTest < ActiveSupport::TestCase
   test "Container request constraints must include valid vcpus and ram fields when committed" do
     set_user_from_auth :active
     # Validations on creation
-    assert_raises(ActiveRecord::RecordInvalid) do
-      cr = create_minimal_req!(state: "Committed", priority: 1,
-                               runtime_constraints: {"vcpus" => 1})
-      cr.save!
-    end
-    assert_raises(ActiveRecord::RecordInvalid) do
-      cr = create_minimal_req!(state: "Committed", priority: 1,
-                               runtime_constraints: {"vcpus" => 1,
-                                                     "ram" => nil})
-      cr.save!
-    end
-    assert_raises(ActiveRecord::RecordInvalid) do
-      cr = create_minimal_req!(state: "Committed", priority: 1,
-                               runtime_constraints: {"vcpus" => 0,
-                                                     "ram" => 123})
-      cr.save!
+    [{"vcpus" => 1},
+     {"vcpus" => 1, "ram" => nil},
+     {"vcpus" => 0, "ram" => 123}].each do |invalid_constraint|
+      assert_raises(ActiveRecord::RecordInvalid) do
+        cr = create_minimal_req!(state: "Committed", priority: 1,
+                                 runtime_constraints: invalid_constraint)
+        cr.save!
+      end
     end
     cr = create_minimal_req!(state: "Committed", priority: 1)
     cr.save!
-
     # Validations on update
     cr = create_minimal_req!(state: "Uncommitted", priority: 1)
     cr.save!
-    cr.state = "Committed"
-    assert_raises(ActiveRecord::RecordInvalid) do
-      cr.runtime_constraints = {"vcpus" => 1}
-      cr.save!
-    end
 
-    cr = create_minimal_req!(state: "Uncommitted", priority: 1)
-    cr.save!
-    cr.state = "Committed"
-    assert_raises(ActiveRecord::RecordInvalid) do
-      cr.runtime_constraints = {"vcpus" => 1, "ram" => nil}
-      cr.save!
-    end
-
-    cr = create_minimal_req!(state: "Uncommitted", priority: 1)
-    cr.save!
-    cr.state = "Committed"
-    assert_raises(ActiveRecord::RecordInvalid) do
-      cr.runtime_constraints = {"vcpus" => 0, "ram" => 123}
-      cr.save!
+    [{"vcpus" => 1},
+     {"vcpus" => 1, "ram" => nil},
+     {"vcpus" => 0, "ram" => 123}].each do |invalid_constraint|
+      cr = ContainerRequest.find_by_uuid cr.uuid
+      assert_raises(ActiveRecord::RecordInvalid) do
+        cr.update_attributes!(state: "Committed",
+                              runtime_constraints: invalid_constraint)
+        cr.save!
+      end
     end
-
-    cr = create_minimal_req!(state: "Uncommitted", priority: 1)
-    cr.save!
-    cr.state = "Committed"
-    cr.runtime_constraints = {"vcpus" => 1, "ram" => 23}
+    cr = ContainerRequest.find_by_uuid cr.uuid
+    cr.update_attributes!(state: "Committed",
+                          runtime_constraints: {"vcpus" => 1, "ram" => 23})
     cr.save!
   end
 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list