X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/7fb83a3380e62721801a4980c48ba78208c7b2e2..7c2d7b25747a06919e8ec64f0b4391c33092d965:/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 b5f09df7c7..a7bd545179 100644 --- a/services/api/test/integration/select_test.rb +++ b/services/api/test/integration/select_test.rb @@ -5,7 +5,7 @@ class SelectTest < ActionDispatch::IntegrationTest get "/arvados/v1/links", {:format => :json, :select => ['uuid', 'link_class']}, auth(:active) assert_response :success assert_equal json_response['items'].count, json_response['items'].select { |i| - i.count == 2 and i['uuid'] != nil and i['link_class'] != nil + i.count == 3 and i['uuid'] != nil and i['link_class'] != nil }.count end @@ -18,7 +18,8 @@ class SelectTest < ActionDispatch::IntegrationTest assert_response :success distinct = json_response['items'] - assert distinct.count < links.count, "distinct count should be less than link count" + assert_operator(distinct.count, :<, links.count, + "distinct count should be less than link count") assert_equal links.uniq.count, distinct.count end @@ -35,6 +36,16 @@ class SelectTest < ActionDispatch::IntegrationTest end end + def assert_link_classes_ascend(current_class, prev_class) + # Databases and Ruby don't always agree about string ordering with + # punctuation. If the strings aren't ascending normally, check + # that they're equal up to punctuation. + if current_class < prev_class + class_prefix = current_class.split(/\W/).first + assert prev_class.start_with?(class_prefix) + end + 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) assert_response :success @@ -49,7 +60,7 @@ class SelectTest < ActionDispatch::IntegrationTest prev_uuid = "zzzzz-zzzzz-zzzzzzzzzzzzzzz" end - assert i['link_class'] >= prev_link_class + assert_link_classes_ascend(i['link_class'], prev_link_class) assert i['uuid'] < prev_uuid prev_link_class = i['link_class'] @@ -71,7 +82,7 @@ class SelectTest < ActionDispatch::IntegrationTest prev_uuid = "zzzzz-zzzzz-zzzzzzzzzzzzzzz" end - assert i['link_class'] >= prev_link_class + assert_link_classes_ascend(i['link_class'], prev_link_class) assert i['uuid'] < prev_uuid prev_link_class = i['link_class']