From 34222842b3a0f26ae20f34674c074c2efb871ff9 Mon Sep 17 00:00:00 2001
From: Allen Gilliland <agilliland@gmail.com>
Date: Fri, 11 Sep 2015 16:44:11 -0700
Subject: [PATCH] a couple small tweaks to our activity unit tests to prevent
 race conditions which intermittently cause test failures.

---
 test/metabase/api/activity_test.clj | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/test/metabase/api/activity_test.clj b/test/metabase/api/activity_test.clj
index b0025e789a2..5e6b4792604 100644
--- a/test/metabase/api/activity_test.clj
+++ b/test/metabase/api/activity_test.clj
@@ -19,7 +19,7 @@
 ;  2. :user and :model_exists are hydrated
 
 ; NOTE: timestamp matching was being a real PITA so I cheated a bit.  ideally we'd fix that
-(expect-let [_         (user->client :crowberto)            ; HACK. we do this to create the user-joined activity after first login before we delete it
+(expect-let [client    (user->client :crowberto)            ; we do this to create the user-joined activity after first login before we clear out activity for the test
              _         (korma.core/delete Activity)         ; clear out any existing activity
              activity1 (db/ins Activity
                          :topic     "install"
@@ -98,7 +98,7 @@
       :table        nil
       :custom_id    nil
       :details      $})]
-  (->> ((user->client :crowberto) :get 200 "activity")
+  (->> (client :get 200 "activity")
        (map #(dissoc % :timestamp))))
 
 
@@ -157,7 +157,8 @@
                         :user_id  user
                         :model    model
                         :model_id model-id
-                        :timestamp (u/new-sql-timestamp)))]
+                        :timestamp (u/new-sql-timestamp))
+                      (Thread/sleep 25))]
     (do
       (create-view (user->id :crowberto) "card" (:id card2))
       (create-view (user->id :crowberto) "dashboard" (:id dash1))
-- 
GitLab