   (testing "that the event bus is notified when a step finishes"
     (let [ctx (some-ctx-with :build-number 3
                              :step-id [1 2 3])
-          step-finished-events (-> (event-bus/subscribe ctx :step-finished)
-                                   (event-bus/only-payload)
-                                   (buffered))]
+          step-finished-events (step-finished-events-for ctx)]
       (execute-step {} [ctx some-other-step])
       (is (= [{:build-number 3
                :step-id [1 2 3]

  (testing "that the context data is being passed on to the step"
    (is (= {:outputs { [0 0] {:status :success :context-info "foo"}} :status :success} (execute-step {} [(some-ctx-with :step-id [0 0] :the-info "foo") some-step-consuming-the-context]))))
  (testing "that the final pipeline-state is properly set for a step returning a static result"
    (let [step-results-channel (async/chan 100)]
      (execute-step {} [(some-ctx-with :step-id [0 0]
                                       :build-number 5
                                       :step-results-channel step-results-channel
                                       :pipeline-state-component (noop-pipeline-state/new-no-op-pipeline-state)) some-successful-step])
      (is (= [{ :build-number 5 :step-id [0 0] :step-result {:status :running } }
              { :build-number 5 :step-id [0 0] :step-result {:status :success } }] (slurp-chan step-results-channel)))))
  (testing "that the final pipeline-state is properly set for a step returning a static and an async result"
    (let [step-results-channel (async/chan 100)]
      (execute-step {} [(some-ctx-with :step-id [0 0]
                                       :build-number 5
                                       :step-results-channel step-results-channel
                                       :pipeline-state-component (noop-pipeline-state/new-no-op-pipeline-state)) some-step-that-sends-failure-on-ch-returns-success])
      (is (= [{ :build-number 5 :step-id [0 0] :step-result {:status :running } }
              { :build-number 5 :step-id [0 0] :step-result {:status :failure } }
              { :build-number 5 :step-id [0 0] :step-result {:status :success } }] (slurp-chan step-results-channel)))))


(defn some-pipeline-state []
  (atom {}))


(defn- step-finished-events-for [ctx]
  (-> (event-bus/subscribe ctx :step-finished)
      (event-bus/only-payload)
      (buffered)))

(defn step-result-updates-for [ctx]
  (-> (event-bus/subscribe ctx :step-result-updated)
      (event-bus/only-payload)
      (buffered)))

(deftest execute-step-test
  (testing "that executing returns the step result added to the input args"
