 (defn- expected-timestamp [state commit-msg]
   (git-utils/commit-timestamp-date (:git @state) (commit-hash-by-msg state commit-msg)))
 
-(deftest wait-for-git-test-clean
+(deftest wait-for-git-test
   (testing "that it waits for a new commit to happen and that it prints out information on old and new commit"
     (let [state (-> (init-state)
                     (git-init)
                     (git-commit "initial commit")
-                    (start-wait-for-git-step-with-ref "refs/heads/master")
+                    (start-wait-for-git-step :ref "refs/heads/master")
                     (wait-for-step-waiting)
                     (git-commit "other commit")
                     (get-step-result))]

              (recur)))))))
  state)

(defn start-wait-for-git-step-with-ref [state ref]
  (let [wait-for-result-channel (async/go
                                  (let [execute-step-result (lambdacd-core/execute-step {} (:ctx @state)
                                                                                        (fn [args ctx]
                                                                                          (wait-for-git ctx (get-in @state [:git :remote]) :ref ref :ms-between-polls 100)))]
                                    (first (vals (:outputs execute-step-result)))))]
    (swap! state #(assoc % :result-channel wait-for-result-channel))
    (wait-for-step-waiting state)
    state))
(defn start-wait-for-git-step [state]
  (let [wait-for-result-channel (async/go
                                  (let [execute-step-result (lambdacd-core/execute-step {} (:ctx @state)
                                                                                        (fn [args ctx]
                                                                                          (wait-for-git ctx (get-in @state [:git :remote]) :ms-between-polls 100)))]
                                    (first (vals (:outputs execute-step-result)))))]
    (swap! state #(assoc % :result-channel wait-for-result-channel))
    (wait-for-step-waiting state)

                    (git-init)
                    (git-commit "initial commit")
                    (git-checkout-b "some-branch")
                    (start-wait-for-git-step :ref (fn [ref] (.endsWith ref "some-branch")))
                    (git-commit "other commit")
                    (get-step-result))]
      (is (= :success (:status (step-result state))))
