11167: Added helper function to be used on collection access tests via keep-web
authorLucas Di Pentima <lucas@curoverse.com>
Mon, 7 Aug 2017 21:34:15 +0000 (18:34 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Mon, 7 Aug 2017 21:34:15 +0000 (18:34 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@curoverse.com>

apps/workbench/test/integration_helper.rb

index efe6bd2b33dd44044f7e24d854ccf933f0f10753..ef2779cc3e78eedb556ce2dc7114a6e2466112b0 100644 (file)
@@ -240,3 +240,19 @@ class ActionDispatch::IntegrationTest
     end
   end
 end
+
+def upload_data_and_get_collection(data, user, filename, owner_uuid=nil)
+  token = api_fixture('api_client_authorizations')[user]['api_token']
+  datablock = `echo -n #{data.shellescape} | ARVADOS_API_TOKEN=#{token.shellescape} arv-put --no-progress --raw -`.strip
+  assert $?.success?, $?
+  col = nil
+  use_token user do
+    mtxt = ". #{datablock} 0:#{data.length}:#{filename}\n"
+    if owner_uuid
+      col = Collection.create(manifest_text: mtxt, owner_uuid: owner_uuid)
+    else
+      col = Collection.create(manifest_text: mtxt)
+    end
+  end
+  return col
+end