smaller commit :)
This commit is contained in:
1 parent
bce64fc8f6
commit
d4bc2490ff
8 files changed
+51
-18
No files matched your search
@@ -34,13 +34,21 @@
|
||||
|
||||
(def sec->hash-set #(apply hash-set %))
|
||||
|
||||
(def mock-securities [[:sec-1 100 :equity "first equity" "rot13"]
|
||||
[:sec-2 200 :equity "second equity" "rot13"]
|
||||
[:sec-3 300 :equity "third equity" "rot13"]])
|
||||
|
||||
(def mock-currencies [[:zimbabwean-dollar 1000000 :currency "zimbabwean dollar" "rot13" "zd"]])
|
||||
|
||||
|
||||
|
||||
|
||||
(defn create-some-securities [conn]
|
||||
(let [cs (create-security conn)
|
||||
create-security-1 {:body (edn->stream [:sec-1 100]) :headers {"accept" "application/edn"}}
|
||||
create-security-2 {:body (edn->stream [:sec-2 200]) :headers {"accept" "application/edn"}}
|
||||
create-security-3 {:body (edn->stream [:sec-3 300]) :headers {"accept" "application/edn"}}
|
||||
create-security-4 {:body (edn->stream [:zimbabwean-dollar 1000000]) :headers {"accept" "application/edn"}}]
|
||||
create-security-1 {:body (edn->stream (get mock-securities 0)) :headers {"accept" "application/edn"}}
|
||||
create-security-2 {:body (edn->stream (get mock-securities 1)) :headers {"accept" "application/edn"}}
|
||||
create-security-3 {:body (edn->stream (get mock-securities 2)) :headers {"accept" "application/edn"}}
|
||||
create-security-4 {:body (edn->stream (first mock-currencies)) :headers {"accept" "application/edn"}}]
|
||||
(->> create-security-1 cs (s/assert ::ok))
|
||||
(->> create-security-2 cs (s/assert ::ok))
|
||||
(->> create-security-3 cs (s/assert ::ok))
|
||||
@@ -67,15 +75,15 @@
|
||||
(facts "about the securities"
|
||||
(fact "We should be able to create a security"
|
||||
(let [conn (create-conn)
|
||||
security [:new-currency 100]
|
||||
security [:new-currency 100 :currency "currency for test" "rot13" "NC"]
|
||||
request {:body (edn->stream security) :headers {"accept" "application/edn"}}
|
||||
resp ((create-security conn) request)]
|
||||
resp => (spec-check ::ok)
|
||||
resp => (location? "/api/1/ledger/securities/new-currency"))) ;;
|
||||
resp => (location? "/api/1/ledger/securities/new-currency")))
|
||||
|
||||
(fact "We should not be able to create a security that already exists"
|
||||
(let [conn (create-conn)
|
||||
security [:new-currency 100]
|
||||
security [:new-currency 100 :currency "currency for test" "rot13" "NC"]
|
||||
request {:body (edn->stream security) :headers {"accept" "application/edn"}}
|
||||
resp-1 ((create-security conn) request)
|
||||
resp-2 ((create-security conn) request)]
|
||||
@@ -87,7 +95,7 @@
|
||||
|
||||
(fact "we should be able to get-security if it does exists"
|
||||
(let [conn (create-conn)
|
||||
security [:new-currency 100]
|
||||
security [:new-currency 100 :currency "currency for test" "rot13" "NC"]
|
||||
create-request {:body (edn->stream security) :headers {"accept" "application/edn"}}
|
||||
_ ((create-security conn) create-request)
|
||||
request {:route-params {:sec-id :new-currency} :headers {"accept" "application/edn"}}
|
||||
@@ -106,7 +114,8 @@
|
||||
(let [conn (create-conn)
|
||||
request {:route-params {} :headers {"accept" "application/edn"}}
|
||||
empty-res ((get-available-securities conn) request)
|
||||
create-security-1 {:body (edn->stream [:new-currency 100]) :headers {"accept" "application/edn"}}
|
||||
new-currency [:new-currency 100 :currency "currency for test" "rot13" "NC"]
|
||||
create-security-1 {:body (edn->stream new-currency) :headers {"accept" "application/edn"}}
|
||||
_ ((create-security conn) create-security-1)
|
||||
one-res ((get-available-securities conn) request)]
|
||||
empty-res => (spec-check ::ok)
|
||||
|
||||
Reference in new issue
Block a user