X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0eb72b526bf8bbb011551ecf019f604e17a534f1..b53513423ab948804425424278ac554870864997:/services/api/test/integration/select_test.rb diff --git a/services/api/test/integration/select_test.rb b/services/api/test/integration/select_test.rb index fb3f4f617a..0548a767ba 100644 --- a/services/api/test/integration/select_test.rb +++ b/services/api/test/integration/select_test.rb @@ -6,7 +6,9 @@ require 'test_helper' class SelectTest < ActionDispatch::IntegrationTest test "should select just two columns" do - get "/arvados/v1/links", {:format => :json, :select => ['uuid', 'link_class']}, auth(:active) + get "/arvados/v1/links", + params: {:format => :json, :select => ['uuid', 'link_class']}, + headers: auth(:active) assert_response :success assert_equal json_response['items'].count, json_response['items'].select { |i| i.count == 3 and i['uuid'] != nil and i['link_class'] != nil @@ -14,21 +16,35 @@ class SelectTest < ActionDispatch::IntegrationTest end test "fewer distinct than total count" do - get "/arvados/v1/links", {:format => :json, :select => ['link_class'], :distinct => false}, auth(:active) + get "/arvados/v1/links", + params: {:format => :json, :select => ['link_class']}, + headers: auth(:active) assert_response :success - links = json_response['items'] + distinct_unspecified = json_response['items'] - get "/arvados/v1/links", {:format => :json, :select => ['link_class'], :distinct => true}, auth(:active) + get "/arvados/v1/links", + params: {:format => :json, :select => ['link_class'], :distinct => false}, + headers: auth(:active) + assert_response :success + distinct_false = json_response['items'] + + get "/arvados/v1/links", + params: {:format => :json, :select => ['link_class'], :distinct => true}, + headers: auth(:active) assert_response :success distinct = json_response['items'] - assert_operator(distinct.count, :<, links.count, - "distinct count should be less than link count") - assert_equal links.uniq.count, distinct.count + assert_operator(distinct.count, :<, distinct_false.count, + "distinct=true count should be less than distinct=false count") + assert_equal(distinct_unspecified.count, distinct_false.count, + "distinct=false should be the default") + assert_equal distinct_false.uniq.count, distinct.count end test "select with order" do - get "/arvados/v1/links", {:format => :json, :select => ['uuid'], :order => ["uuid asc"]}, auth(:active) + get "/arvados/v1/links", + params: {:format => :json, :select => ['uuid'], :order => ["uuid asc"]}, + headers: auth(:active) assert_response :success assert json_response['items'].length > 0 @@ -41,10 +57,12 @@ class SelectTest < ActionDispatch::IntegrationTest end test "select with default order" do - get "/arvados/v1/links", {format: :json, select: ['uuid']}, auth(:admin) + get "/arvados/v1/links", + params: {format: :json, select: ['uuid']}, + headers: auth(:admin) assert_response :success uuids = json_response['items'].collect { |i| i['uuid'] } - assert_equal uuids, uuids.sort + assert_equal uuids, uuids.sort.reverse end def assert_link_classes_ascend(current_class, prev_class) @@ -58,7 +76,12 @@ class SelectTest < ActionDispatch::IntegrationTest end test "select two columns with order" do - get "/arvados/v1/links", {:format => :json, :select => ['link_class', 'uuid'], :order => ['link_class asc', "uuid desc"]}, auth(:active) + get "/arvados/v1/links", + params: { + :format => :json, + :select => ['link_class', 'uuid'], :order => ['link_class asc', "uuid desc"] + }, + headers: auth(:active) assert_response :success assert json_response['items'].length > 0 @@ -80,7 +103,12 @@ class SelectTest < ActionDispatch::IntegrationTest end test "select two columns with old-style order syntax" do - get "/arvados/v1/links", {:format => :json, :select => ['link_class', 'uuid'], :order => 'link_class asc, uuid desc'}, auth(:active) + get "/arvados/v1/links", + params: { + :format => :json, + :select => ['link_class', 'uuid'], :order => 'link_class asc, uuid desc' + }, + headers: auth(:active) assert_response :success assert json_response['items'].length > 0