Merge branch 'master' into 1971-show-image-thumbnails
[arvados.git] / services / api / test / functional / arvados / v1 / jobs_controller_test.rb
index 2b508834a753f62ce133099fde2ccdc6ebeacc48..9904c833c8ca7ae6841d7e3dbbd440c48607b291 100644 (file)
@@ -1,12 +1,16 @@
 require 'test_helper'
+load 'test/functional/arvados/v1/git_setup.rb'
 
 class Arvados::V1::JobsControllerTest < ActionController::TestCase
 
+  include GitSetup
+
   test "submit a job" do
     authorize_with :active
     post :create, job: {
       script: "hash",
       script_version: "master",
+      repository: "foo",
       script_parameters: {}
     }
     assert_response :success
@@ -14,6 +18,8 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
     new_job = JSON.parse(@response.body)
     assert_not_nil new_job['uuid']
     assert_not_nil new_job['script_version'].match(/^[0-9a-f]{40}$/)
+    # Default: not persistent
+    assert_equal false, new_job['output_is_persistent']
   end
 
   test "normalize output and log uuids when creating job" do
@@ -22,6 +28,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
       script: "hash",
       script_version: "master",
       script_parameters: {},
+      repository: "foo",
       started_at: Time.now,
       finished_at: Time.now,
       running: false,
@@ -107,7 +114,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   test "search jobs by uuid with >= query" do
     authorize_with :active
     get :index, {
-      where: [['uuid', '>=', 'zzzzz-8i9sb-pshmckwoma9plh7']]
+      filters: [['uuid', '>=', 'zzzzz-8i9sb-pshmckwoma9plh7']]
     }
     assert_response :success
     found = assigns(:objects).collect(&:uuid)
@@ -118,7 +125,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   test "search jobs by uuid with <= query" do
     authorize_with :active
     get :index, {
-      where: [['uuid', '<=', 'zzzzz-8i9sb-pshmckwoma9plh7']]
+      filters: [['uuid', '<=', 'zzzzz-8i9sb-pshmckwoma9plh7']]
     }
     assert_response :success
     found = assigns(:objects).collect(&:uuid)
@@ -129,7 +136,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   test "search jobs by uuid with >= and <= query" do
     authorize_with :active
     get :index, {
-      where: [['uuid', '>=', 'zzzzz-8i9sb-pshmckwoma9plh7'],
+      filters: [['uuid', '>=', 'zzzzz-8i9sb-pshmckwoma9plh7'],
               ['uuid', '<=', 'zzzzz-8i9sb-pshmckwoma9plh7']]
     }
     assert_response :success
@@ -140,7 +147,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   test "search jobs by uuid with < query" do
     authorize_with :active
     get :index, {
-      where: [['uuid', '<', 'zzzzz-8i9sb-pshmckwoma9plh7']]
+      filters: [['uuid', '<', 'zzzzz-8i9sb-pshmckwoma9plh7']]
     }
     assert_response :success
     found = assigns(:objects).collect(&:uuid)
@@ -151,7 +158,7 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   test "search jobs by uuid with like query" do
     authorize_with :active
     get :index, {
-      where: [['uuid', 'like', '%hmckwoma9pl%']]
+      filters: [['uuid', 'like', '%hmckwoma9pl%']]
     }
     assert_response :success
     found = assigns(:objects).collect(&:uuid)
@@ -161,8 +168,8 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
   test "search jobs by uuid with 'in' query" do
     authorize_with :active
     get :index, {
-      where: [['uuid', 'in', ['zzzzz-8i9sb-4cf0nhn6xte809j',
-                              'zzzzz-8i9sb-pshmckwoma9plh7']]]
+      filters: [['uuid', 'in', ['zzzzz-8i9sb-4cf0nhn6xte809j',
+                                'zzzzz-8i9sb-pshmckwoma9plh7']]]
     }
     assert_response :success
     found = assigns(:objects).collect(&:uuid)
@@ -170,11 +177,63 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
                               'zzzzz-8i9sb-pshmckwoma9plh7']
   end
 
+  test "search jobs by started_at with < query" do
+    authorize_with :active
+    get :index, {
+      filters: [['started_at', '<', Time.now.to_s]]
+    }
+    assert_response :success
+    found = assigns(:objects).collect(&:uuid)
+    assert_equal true, !!found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+  end
+
+  test "search jobs by started_at with > query" do
+    authorize_with :active
+    get :index, {
+      filters: [['started_at', '>', Time.now.to_s]]
+    }
+    assert_response :success
+    assert_equal 0, assigns(:objects).count
+  end
+
+  test "search jobs by started_at with >= query on metric date" do
+    authorize_with :active
+    get :index, {
+      filters: [['started_at', '>=', '2014-01-01']]
+    }
+    assert_response :success
+    found = assigns(:objects).collect(&:uuid)
+    assert_equal true, !!found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+  end
+
+  test "search jobs by started_at with >= query on metric date and time" do
+    authorize_with :active
+    get :index, {
+      filters: [['started_at', '>=', '2014-01-01 01:23:45']]
+    }
+    assert_response :success
+    found = assigns(:objects).collect(&:uuid)
+    assert_equal true, !!found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+  end
+
+  test "search jobs with 'any' operator" do
+    authorize_with :active
+    get :index, {
+      where: { any: ['contains', 'pshmckw'] }
+    }
+    assert_response :success
+    found = assigns(:objects).collect(&:uuid)
+    assert_equal 0, found.index('zzzzz-8i9sb-pshmckwoma9plh7')
+    assert_equal 1, found.count
+  end
+
   test "search jobs by nonexistent column with < query" do
     authorize_with :active
     get :index, {
-      where: [['is_borked', '<', 'fizzbuzz']]
+      filters: [['is_borked', '<', 'fizzbuzz']]
     }
     assert_response 422
   end
+
+
 end