Skip to content

Instantly share code, notes, and snippets.

@ulises
Created April 17, 2013 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ulises/5404292 to your computer and use it in GitHub Desktop.
Save ulises/5404292 to your computer and use it in GitHub Desktop.
(defn mock-sink []
(let [call-count (atom 0)
call-args (atom "no args yet")]
(with-meta (fn [_]
(fn [event]
(swap! call-count inc)
(reset! call-args event)))
{:call-count call-count
:call-args call-args})))
(defn call-count [mock]
@(:call-count (meta mock)))
(fact "a hammered sink should not throw"
(with-redefs [riemann.graphite/graphite (mock-sink)]
(let [sink (init-internal {:host "fake"})
events 120000
_ (last (map deref (map (fn [_] (future (sink ..event..))) (range events))))]
(call-count riemann.graphite/graphite) => events)))
;; fails with
FAIL "about the performance of graphite sinks - a hammered sink should not throw" at (graphite_test.clj:65)
Expected: 120000
Actual: 119997
FAILURE: 1 check failed. (But 31 succeeded.)
Subprocess failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment