Added support for :distinct to application controller. User can now specify a
[arvados.git] / services / api / test / integration / select_test.rb
1 require 'test_helper'
2
3 class SelectTest < ActionDispatch::IntegrationTest
4   test "should select just two columns" do
5     get "/arvados/v1/links", {:format => :json, :select => ['uuid', 'link_class']}, auth(:active)
6     assert_response :success
7     assert_equal json_response['items'].count, json_response['items'].select { |i|
8       i['uuid'] != nil and i['link_class'] != nil and i['head_uuid'] == nil and i['tail_uuid'] == nil
9     }.count
10   end
11
12   test "should only get distinct values" do
13     get "/arvados/v1/links", {:format => :json, :select => ['link_class'], :distinct => "link_class"}, auth(:active)
14     assert_response :success
15     assert_equal json_response['items'].uniq.count, json_response['items'].count
16   end
17
18 end