2018-02-20 02:48:03 +00:00
|
|
|
(ns day8.re-frame-10x.metamorphic-test
|
2017-12-22 03:40:43 +00:00
|
|
|
(:require [clojure.test :refer :all])
|
2018-02-20 02:48:03 +00:00
|
|
|
(:require [day8.re-frame-10x.metamorphic :as m]))
|
2017-12-22 03:40:43 +00:00
|
|
|
|
2018-01-11 03:26:55 +00:00
|
|
|
(defn trace-events [file]
|
|
|
|
(->> (slurp (str "test-resources/" file))
|
|
|
|
(clojure.edn/read-string {:readers {'utc identity
|
|
|
|
'object (fn [x] "<object>")}})
|
|
|
|
(sort-by :id)))
|
|
|
|
|
|
|
|
(deftest parse-app-trace1-test
|
2018-02-01 01:22:02 +00:00
|
|
|
(let [rt (m/parse-traces m/initial-parse-state (trace-events "app-trace1.edn"))
|
|
|
|
matches (:partitions rt)
|
2018-01-11 03:26:55 +00:00
|
|
|
[m1 m2 m3 m4 m5 m6] matches]
|
|
|
|
(is (= (count matches) 6))
|
|
|
|
|
|
|
|
(is (= (m/beginning-id m1) 1))
|
|
|
|
(is (= (m/ending-id m1) 34))
|
|
|
|
(is (= (:operation (m/matched-event m1)) :bootstrap))
|
|
|
|
|
|
|
|
(is (= (m/beginning-id m2) 35))
|
|
|
|
(is (= (m/ending-id m2) 38))
|
|
|
|
(is (= (:operation (m/matched-event m2)) :acme.myapp.events/boot-flow))
|
|
|
|
|
|
|
|
(is (= (m/beginning-id m3) 39))
|
|
|
|
(is (= (m/ending-id m3) 42))
|
|
|
|
(is (= (:operation (m/matched-event m3)) :acme.myapp.events/init-db))
|
|
|
|
|
|
|
|
(is (= (m/beginning-id m4) 43))
|
|
|
|
(is (= (m/ending-id m4) 47))
|
|
|
|
(is (= (:operation (m/matched-event m4)) :acme.myapp.events/boot-flow))
|
|
|
|
|
|
|
|
(is (= (m/beginning-id m5) 48))
|
|
|
|
(is (= (m/ending-id m5) 49))
|
|
|
|
(is (= (:operation (m/matched-event m5)) :acme.myapp.events/start-intercom))
|
|
|
|
|
|
|
|
(is (= (m/beginning-id m6) 50))
|
|
|
|
(is (= (m/ending-id m6) 181))
|
|
|
|
(is (= (:operation (m/matched-event m6)) :acme.myapp.events/success-bootstrap))))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
|
|
|
#_(deftest parse-todomvc-trace1-test
|
2018-02-01 01:32:14 +00:00
|
|
|
(let [rt (m/parse-traces (trace-events "todomvc-trace1.edn"))
|
|
|
|
matches (:matches rt)
|
|
|
|
[m1 m2 m3 m4 m5 m6] matches]
|
|
|
|
(is (= (count matches) 3))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
2018-02-01 01:32:14 +00:00
|
|
|
(is (= (m/beginning-id m1) 1))
|
|
|
|
(is (= (m/ending-id m1) 34))
|
|
|
|
(is (= (:operation (m/matched-event m1)) :bootstrap))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
2018-02-01 01:32:14 +00:00
|
|
|
(is (= (m/beginning-id m2) 35))
|
|
|
|
(is (= (m/ending-id m2) 38))
|
|
|
|
(is (= (:operation (m/matched-event m2)) :acme.myapp.events/boot-flow))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
2018-02-01 01:32:14 +00:00
|
|
|
(is (= (m/beginning-id m3) 39))
|
|
|
|
(is (= (m/ending-id m3) 42))
|
|
|
|
(is (= (:operation (m/matched-event m3)) :acme.myapp.events/init-db))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
2018-02-01 01:32:14 +00:00
|
|
|
(is (= (m/beginning-id m4) 43))
|
|
|
|
(is (= (m/ending-id m4) 47))
|
|
|
|
(is (= (:operation (m/matched-event m4)) :acme.myapp.events/boot-flow))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
2018-02-01 01:32:14 +00:00
|
|
|
(is (= (m/beginning-id m5) 48))
|
|
|
|
(is (= (m/ending-id m5) 49))
|
|
|
|
(is (= (:operation (m/matched-event m5)) :acme.myapp.events/start-intercom))
|
2018-01-18 22:25:23 +00:00
|
|
|
|
2018-02-01 01:32:14 +00:00
|
|
|
(is (= (m/beginning-id m6) 50))
|
|
|
|
(is (= (m/ending-id m6) 181))
|
|
|
|
(is (= (:operation (m/matched-event m6)) :acme.myapp.events/success-bootstrap))))
|