4523: add a few functional tests for collections with file_names testing.
[arvados.git] / services / api / test / integration / groups_test.rb
1 require 'test_helper'
2
3 class GroupsTest < ActionDispatch::IntegrationTest
4
5   test "get all pages of group-owned objects" do
6     limit = 5
7     offset = 0
8     items_available = nil
9     uuid_received = {}
10     owner_received = {}
11     while true
12       @json_response = nil
13
14       get "/arvados/v1/groups/contents", {
15         id: groups(:aproject).uuid,
16         limit: limit,
17         offset: offset,
18         format: :json,
19       }, auth(:active)
20
21       assert_response :success
22       assert_operator(0, :<, json_response['items'].count,
23                       "items_available=#{items_available} but received 0 "\
24                       "items with offset=#{offset}")
25       items_available ||= json_response['items_available']
26       assert_equal(items_available, json_response['items_available'],
27                    "items_available changed between page #{offset/limit} "\
28                    "and page #{1+offset/limit}")
29       json_response['items'].each do |item|
30         uuid = item['uuid']
31         assert_equal(nil, uuid_received[uuid],
32                      "Received '#{uuid}' again on page #{1+offset/limit}")
33         uuid_received[uuid] = true
34         owner_received[item['owner_uuid']] = true
35         offset += 1
36         assert_equal groups(:aproject).uuid, item['owner_uuid']
37       end
38       break if offset >= items_available
39     end
40   end
41
42 end