Merge branch 'master' into 4232-slow-pipes-n-jobs
[arvados.git] / services / api / test / integration / groups_test.rb
index f37b9860b52faa3a98008bad888ff4a11a8711fd..2afece9563c092a1ad221883ba601e9334de3aa0 100644 (file)
@@ -1,6 +1,25 @@
 require 'test_helper'
 
 class GroupsTest < ActionDispatch::IntegrationTest
+  [[], ['replication_confirmed']].each do |orders|
+    test "results are consistent when provided orders #{orders} is incomplete" do
+      last = nil
+      (0..20).each do
+        get '/arvados/v1/groups/contents', {
+          id: groups(:aproject).uuid,
+          filters: [["uuid", "is_a", "arvados#collection"]].to_json,
+          orders: orders.to_json,
+          format: :json,
+        }, auth(:active)
+        assert_response :success
+        if last.nil?
+          last = json_response['items']
+        else
+          assert_equal last, json_response['items']
+        end
+      end
+    end
+  end
 
   test "get all pages of group-owned objects" do
     limit = 5
@@ -9,8 +28,6 @@ class GroupsTest < ActionDispatch::IntegrationTest
     uuid_received = {}
     owner_received = {}
     while true
-      @json_response = nil
-
       get "/arvados/v1/groups/contents", {
         id: groups(:aproject).uuid,
         limit: limit,
@@ -40,10 +57,14 @@ class GroupsTest < ActionDispatch::IntegrationTest
   end
 
   [
-    ['Collection_', true],           # collections and pipelines templates
-    ['hash', true],                  # pipeline templates
-    ['fa7aeb5140e2848d39b', true],   # script_parameter of pipeline instances
-    ['no-such-thing', false],        # script_parameter of pipeline instances
+    ['Collection_', true],            # collections and pipelines templates
+    ['hash', true],                   # pipeline templates
+    ['fa7aeb5140e2848d39b', false],   # script_parameter of pipeline instances
+    ['fa7aeb5140e2848d39b:*', true],  # script_parameter of pipeline instances
+    ['project pipeline', true],       # finds "Completed pipeline in A Project"
+    ['project pipeli:*', true],       # finds "Completed pipeline in A Project"
+    ['proje pipeli:*', false],        # first word is incomplete, so no prefix match
+    ['no-such-thing', false],         # script_parameter of pipeline instances
   ].each do |search_filter, expect_results|
     test "full text search of group-owned objects for #{search_filter}" do
       get "/arvados/v1/groups/contents", {
@@ -53,17 +74,21 @@ class GroupsTest < ActionDispatch::IntegrationTest
       }, auth(:active)
       assert_response :success
       if expect_results
-        assert_operator(0, :<, json_response['items'].count,
-                        "expected results but received 0")
+        refute_empty json_response['items']
         json_response['items'].each do |item|
           assert item['uuid']
           assert_equal groups(:aproject).uuid, item['owner_uuid']
         end
       else
-        assert_operator(0, :==, json_response['items'].count,
-                        "expected no results but received #{json_response['items'].length}")
+        assert_empty json_response['items']
       end
     end
   end
 
+  test "full text search is not supported for individual columns" do
+    get "/arvados/v1/groups/contents", {
+      :filters => [['name', '@@', 'Private']].to_json
+    }, auth(:active)
+    assert_response 422
+  end
 end