1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class GroupsTest < ActionDispatch::IntegrationTest
8 [[], ['replication_confirmed']].each do |orders|
9 test "results are consistent when provided orders #{orders} is incomplete" do
12 get '/arvados/v1/groups/contents', {
13 id: groups(:aproject).uuid,
14 filters: [["uuid", "is_a", "arvados#collection"]].to_json,
15 orders: orders.to_json,
18 assert_response :success
20 last = json_response['items']
22 assert_equal last, json_response['items']
28 test "get all pages of group-owned objects" do
35 get "/arvados/v1/groups/contents", {
36 id: groups(:aproject).uuid,
42 assert_response :success
43 assert_operator(0, :<, json_response['items'].count,
44 "items_available=#{items_available} but received 0 "\
45 "items with offset=#{offset}")
46 items_available ||= json_response['items_available']
47 assert_equal(items_available, json_response['items_available'],
48 "items_available changed between page #{offset/limit} "\
49 "and page #{1+offset/limit}")
50 json_response['items'].each do |item|
52 assert_equal(nil, uuid_received[uuid],
53 "Received '#{uuid}' again on page #{1+offset/limit}")
54 uuid_received[uuid] = true
55 owner_received[item['owner_uuid']] = true
57 assert_equal groups(:aproject).uuid, item['owner_uuid']
59 break if offset >= items_available
64 ['Collection_', true], # collections and pipelines templates
65 ['hash', true], # pipeline templates
66 ['fa7aeb5140e2848d39b', false], # script_parameter of pipeline instances
67 ['fa7aeb5140e2848d39b:*', true], # script_parameter of pipeline instances
68 ['project pipeline', true], # finds "Completed pipeline in A Project"
69 ['project pipeli:*', true], # finds "Completed pipeline in A Project"
70 ['proje pipeli:*', false], # first word is incomplete, so no prefix match
71 ['no-such-thing', false], # script_parameter of pipeline instances
72 ].each do |search_filter, expect_results|
73 test "full text search of group-owned objects for #{search_filter}" do
74 get "/arvados/v1/groups/contents", {
75 id: groups(:aproject).uuid,
77 :filters => [['any', '@@', search_filter]].to_json
79 assert_response :success
81 refute_empty json_response['items']
82 json_response['items'].each do |item|
84 assert_equal groups(:aproject).uuid, item['owner_uuid']
87 assert_empty json_response['items']
92 test "full text search is not supported for individual columns" do
93 get "/arvados/v1/groups/contents", {
94 :filters => [['name', '@@', 'Private']].to_json
99 test "group contents with include trash collections" do
100 get "/arvados/v1/groups/contents", {
101 include_trash: "true",
102 filters: [["uuid", "is_a", "arvados#collection"]].to_json,
108 json_response['items'].each { |c| coll_uuids << c['uuid'] }
109 assert_includes coll_uuids, collections(:foo_collection_in_aproject).uuid
110 assert_includes coll_uuids, collections(:expired_collection).uuid
113 test "group contents without trash collections" do
114 get "/arvados/v1/groups/contents", {
115 filters: [["uuid", "is_a", "arvados#collection"]].to_json,
121 json_response['items'].each { |c| coll_uuids << c['uuid'] }
122 assert_includes coll_uuids, collections(:foo_collection_in_aproject).uuid
123 assert_not_includes coll_uuids, collections(:expired_collection).uuid