20032: Fix unnecessary race in test.
[arvados.git] / apps / workbench / test / unit / work_unit_test.rb
index 1daf582553bf5ce0283e2cd4dfc0550753ca846e..4e5ad396789eb57c582101ba868a88e1a854d4d8 100644 (file)
@@ -9,7 +9,7 @@ class WorkUnitTest < ActiveSupport::TestCase
   reset_api_fixtures :after_each_test, false
 
   setup do
-    Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+    Rails.configuration.Users.AnonymousUserToken = api_fixture('api_client_authorizations')['anonymous']['api_token']
   end
 
   [
@@ -32,12 +32,18 @@ class WorkUnitTest < ActiveSupport::TestCase
 
       if label != nil
         assert_equal(label, wu.label)
+      elsif obj.name.nil?
+        assert_nil(wu.label)
       else
         assert_equal(obj.name, wu.label)
       end
       assert_equal(obj['uuid'], wu.uuid)
       assert_equal(state, wu.state_label)
-      assert_equal(success, wu.success?)
+      if success.nil?
+        assert_nil(wu.success?)
+      else
+        assert_equal(success, wu.success?)
+      end
       assert_equal(progress, wu.progress)
 
       assert_equal(num_children, wu.children.size)
@@ -74,7 +80,11 @@ class WorkUnitTest < ActiveSupport::TestCase
       if walltime
         assert_equal true, (wu.walltime >= walltime)
       else
-        assert_equal walltime, wu.walltime
+        if walltime.nil?
+          assert_nil wu.walltime
+        else
+          assert_equal walltime, wu.walltime
+        end
       end
 
       if cputime
@@ -85,6 +95,8 @@ class WorkUnitTest < ActiveSupport::TestCase
 
       if queuedtime
         assert_equal true, (wu.queuedtime >= queuedtime)
+      elsif queuedtime.nil?
+        assert_nil wu.queuedtime
       else
         assert_equal queuedtime, wu.queuedtime
       end