   (:require [foosball.models.db :refer :all]
             [com.stuartsierra.component :as c]
             [foosball.models.domains :as d]
+            [foosball.util :as util]
             [clojure.test :refer :all]
-            [taoensso.timbre :as t]))
+            [clojure.data :as data]
+            [taoensso.timbre :as t]
+            [clojure.pprint :refer [pprint]]))
 
 (defn memory-db []
   (c/start

  (testing "Creating matches"
    (let [db            (memory-db)
          create-player (fn [seed]
                          (let [id (make-uuid)]
                            (d/create-player! db id (str "name" seed) (str "openid" seed))
                            id))
          [p1 p2 p3 p4] (map create-player ["p1" "p2" "p3" "p3"])
          match-date (java.util.Date.)]
      (testing "We can create a match with our four players"
        (is (not= nil (d/create-match! db {:matchdate match-date
                                           :team1 {:player1 p1 :player2 p2 :score 10}
                                           :team2 {:player1 p3 :player2 p4 :score 5}
                                           :reported-by p1})))))))

                     :id id}] (d/get-players db))))

          (testing "we can get the player be his openid"
            (is (diff-with-first-nil? {:playername name
                                       :playerid id} (d/get-player-with-given-openid db openid))))

          (testing "we can inactivate him,"
            (is (not= nil (d/deactivate-player! db id)))
            (testing "then he is inactive"
              (is (diff-with-first-nil? {:active false} (first (d/get-players db))))))

          (testing "we can reactivate him,"
            (is (not= nil (d/activate-player! db id)))
            (testing "then he is active again"
              (is (diff-with-first-nil? {:active true} (first (d/get-players db))))))
          (testing "we can rename our player,"
            (let [new-name "jeffrey"]
              (is (not= nil (d/rename-player! db id new-name)))
