[ARVADOS] updated: 73c06c1a5af0e62fb937304fa6bee19225b9d7f6
Git user
git at public.curoverse.com
Tue Aug 2 10:54:02 EDT 2016
Summary of changes:
services/api/test/unit/container_request_test.rb | 45 ++++++++++++------------
1 file changed, 23 insertions(+), 22 deletions(-)
via 73c06c1a5af0e62fb937304fa6bee19225b9d7f6 (commit)
from b0993528fa57bb1866bbd6a2b19822cc75010a66 (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 73c06c1a5af0e62fb937304fa6bee19225b9d7f6
Author: Lucas Di Pentima <lucas at curoverse.com>
Date: Tue Aug 2 11:50:05 2016 -0300
9617: Reorganized code reusing the invalid_constraint list on both create & update tests. Separated the successful test case to be on its own.
diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 4db7b18..97663cf 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -53,14 +53,14 @@ class ContainerRequestTest < ActiveSupport::TestCase
assert_nil cr.container_uuid
end
- test "Container request constraints must include valid vcpus and ram fields when committed" do
- set_user_from_auth :active
-
- # Validations on creation
- [{"vcpus" => 1},
- {"vcpus" => 1, "ram" => nil},
- {"vcpus" => 0, "ram" => 123},
- {"vcpus" => "1", "ram" => "123"}].each do |invalid_constraint|
+ [
+ {"vcpus" => 1},
+ {"vcpus" => 1, "ram" => nil},
+ {"vcpus" => 0, "ram" => 123},
+ {"vcpus" => "1", "ram" => "123"}
+ ].each do |invalid_constraint|
+ test "Create with #{invalid_constraint}" do
+ set_user_from_auth :active
assert_raises(ActiveRecord::RecordInvalid) do
cr = create_minimal_req!(state: "Committed",
priority: 1,
@@ -69,25 +69,26 @@ class ContainerRequestTest < ActiveSupport::TestCase
end
end
- # Validations on update
- cr = create_minimal_req!(state: "Uncommitted", priority: 1)
- cr.save!
- [{"vcpus" => 1},
- {"vcpus" => 1, "ram" => nil},
- {"vcpus" => 0, "ram" => 123},
- {"vcpus" => "1", "ram" => "123"}].each do |invalid_constraint|
- cr = ContainerRequest.find_by_uuid cr.uuid
+ test "Update with #{invalid_constraint}" do
+ set_user_from_auth :active
+ cr = create_minimal_req!(state: "Uncommitted", priority: 1)
+ cr.save!
assert_raises(ActiveRecord::RecordInvalid) do
+ cr = ContainerRequest.find_by_uuid cr.uuid
cr.update_attributes!(state: "Committed",
runtime_constraints: invalid_constraint)
- cr.save!
end
end
- cr = ContainerRequest.find_by_uuid cr.uuid
- cr.update_attributes!(state: "Committed",
- runtime_constraints: {"vcpus" => 1, "ram" => 23})
- cr.save!
- assert_not_nil cr.container_uuid
+ end
+
+ test "Update with valid constraint" do
+ set_user_from_auth :active
+ cr = create_minimal_req!(state: "Uncommitted", priority: 1)
+ cr.save!
+ cr = ContainerRequest.find_by_uuid cr.uuid
+ cr.update_attributes!(state: "Committed",
+ runtime_constraints: {"vcpus" => 1, "ram" => 23})
+ assert_not_nil cr.container_uuid
end
test "Container request priority must be non-nil" do
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list