1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class Arvados::V1::QueryTest < ActionController::TestCase
8 test 'no fallback orders when order is unambiguous' do
9 @controller = Arvados::V1::LogsController.new
10 authorize_with :active
15 assert_response :success
16 assert_equal ['logs.id asc'], assigns(:objects).order_values
19 test 'fallback orders when order is ambiguous' do
20 @controller = Arvados::V1::LogsController.new
21 authorize_with :active
23 order: ['event_type asc'],
26 assert_response :success
27 assert_equal('logs.event_type asc, logs.modified_at desc, logs.uuid',
28 assigns(:objects).order_values.join(', '))
31 test 'skip fallback orders already given by client' do
32 @controller = Arvados::V1::LogsController.new
33 authorize_with :active
35 order: ['modified_at asc'],
38 assert_response :success
39 assert_equal('logs.modified_at asc, logs.uuid',
40 assigns(:objects).order_values.join(', '))
43 test 'eliminate superfluous orders' do
44 @controller = Arvados::V1::LogsController.new
45 authorize_with :active
47 order: ['logs.modified_at asc',
50 'logs.event_type asc'],
53 assert_response :success
54 assert_equal('logs.modified_at asc, logs.event_type desc, logs.uuid',
55 assigns(:objects).order_values.join(', '))
58 test 'eliminate orders after the first unique column' do
59 @controller = Arvados::V1::LogsController.new
60 authorize_with :active
62 order: ['event_type asc',
68 assert_response :success
69 assert_equal('logs.event_type asc, logs.id asc',
70 assigns(:objects).order_values.join(', '))
73 test 'do not count items_available if count=none' do
74 @controller = Arvados::V1::LinksController.new
75 authorize_with :active
79 assert_response(:success)
80 refute(json_response.has_key?('items_available'))
83 [{}, {count: nil}, {count: ''}, {count: 'exact'}].each do |params|
84 test "count items_available if params=#{params.inspect}" do
85 @controller = Arvados::V1::LinksController.new
86 authorize_with :active
88 assert_response(:success)
89 assert_operator(json_response['items_available'], :>, 0)
93 test 'error if count=bogus' do
94 @controller = Arvados::V1::LinksController.new
95 authorize_with :active