|
20 | 20 | (with-open [s (test-server state)
|
21 | 21 | c (test-client)]
|
22 | 22 | (c {:funnel/whoami {:id 123}})
|
23 |
| - (will (= [{:whoami {:id 123}}] (vals @state))) |
| 23 | + (will (= [{:whoami {:id 123} |
| 24 | + :format :transit}] (vals @state))) |
24 | 25 |
|
25 | 26 | (c {:funnel/whoami {:id :abc :hello :world}})
|
26 |
| - (will (= [{:whoami {:id :abc :hello :world}}] (vals @state))) |
| 27 | + (will (= [{:whoami {:id :abc :hello :world} |
| 28 | + :format :transit}] (vals @state))) |
27 | 29 |
|
28 | 30 | (with-open [c2 (test-client)]
|
29 | 31 | (c2 {:funnel/whoami {:root "/x/y/z"}})
|
30 | 32 |
|
31 | 33 | (will (match? (m/in-any-order [{:whoami {:id :abc
|
32 |
| - :hello :world}} |
33 |
| - {:whoami {:root "/x/y/z"}}]) |
| 34 | + :hello :world} |
| 35 | + :format :transit} |
| 36 | + {:whoami {:root "/x/y/z"} |
| 37 | + :format :transit}]) |
34 | 38 | (vals @state))))
|
35 | 39 |
|
36 | 40 | (testing "closing will clean up the client connection"
|
37 |
| - (will (= [{:whoami {:id :abc :hello :world}}] (vals @state))))))) |
| 41 | + (will (= [{:whoami {:id :abc :hello :world} |
| 42 | + :format :transit}] (vals @state))))))) |
38 | 43 |
|
39 | 44 | (deftest subscribe-test
|
40 | 45 | (testing "messages get forwarded to subscriber"
|
|
47 | 52 | :funnel/subscribe [:id 2]})
|
48 | 53 | ;; Checkpoint to prevent race conditions, we only continue when funnel
|
49 | 54 | ;; has registered the subscription.
|
50 |
| - (will (= [{:whoami {:id 1}, :subscriptions #{[:id 2]}}] |
| 55 | + (will (= [{:whoami {:id 1} :subscriptions #{[:id 2]} :format :transit} |
| 56 | + {:format :transit} |
| 57 | + {:format :transit}] |
51 | 58 | (vals @state)))
|
52 | 59 |
|
53 | 60 | (c2 {:funnel/whoami {:id 2}
|
|
67 | 74 | (with-open [s (test-server state)
|
68 | 75 | c (test-client)]
|
69 | 76 | (c {:funnel/subscribe [:foo :bar]})
|
70 |
| - (will (= [{:subscriptions #{[:foo :bar]}}] (vals @state))) |
| 77 | + (will (= [{:subscriptions #{[:foo :bar]} :format :transit}] (vals @state))) |
71 | 78 | (c {:funnel/unsubscribe [:foo :bar]})
|
72 |
| - (will (= [{:subscriptions #{}}] (vals @state)))))) |
| 79 | + (will (= [{:subscriptions #{} :format :transit}] (vals @state)))))) |
73 | 80 |
|
74 | 81 | (deftest match-selector-test
|
75 | 82 | (testing "vector"
|
|
78 | 85 | (is (not (funnel/match-selector? {:id 123} [:id 456]))))
|
79 | 86 |
|
80 | 87 | (testing "true"
|
81 |
| - (is (funnel/match-selector? {:id 123} true)) |
82 |
| - (is (funnel/match-selector? nil true))) |
| 88 | + (is (funnel/match-selector? {:id 123} true))) |
| 89 | + |
| 90 | + (testing "no whoami" |
| 91 | + (is (not (funnel/match-selector? nil true)))) |
83 | 92 |
|
84 | 93 | (testing "map"
|
85 | 94 | (is (funnel/match-selector? {:type :x :subtype :a} {:type :x}))
|
|
88 | 97 |
|
89 | 98 | (deftest destinations-test
|
90 | 99 | (let [state {:ws1 {:whoami {:id :ws1}
|
91 |
| - :subscriptions #{[:id :ws2]}} |
92 |
| - :ws2 {:whoami {:id :ws2}} |
93 |
| - :ws3 {:whoami {:id :ws3}}}] |
| 100 | + :subscriptions #{[:id :ws2]} |
| 101 | + :format :transit} |
| 102 | + :ws2 {:whoami {:id :ws2} |
| 103 | + :format :transit} |
| 104 | + :ws3 {:whoami {:id :ws3} |
| 105 | + :format :transit}}] |
94 | 106 |
|
95 | 107 | (is (= [:ws1] (funnel/destinations :ws2 nil state)))
|
96 | 108 | (is (match? (m/in-any-order [:ws1 :ws3])
|
|
0 commit comments