Skip to content

Commit

Permalink
2: Payment (basic)
Browse files Browse the repository at this point in the history
  • Loading branch information
ducki2p committed Jan 1, 2011
1 parent 8d177d8 commit 5a3c418
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/i2conomy/core.clj

This file was deleted.

18 changes: 18 additions & 0 deletions src/i2conomy/mint.clj
@@ -0,0 +1,18 @@
(ns i2conomy.mint)

(def transfers (ref ()))

(defrecord Transfer [timestamp from to currency amount memo])

(defn pay
"Makes a payment between accounts"
[from to currency amount memo]
(dosync
(let [now (java.util.Date.)]
(alter transfers conj (Transfer. now from to currency amount memo)))))

(defn reset-all!
"Reset all transfers, use with care"
[]
(dosync
(ref-set transfers ())))
6 changes: 0 additions & 6 deletions test/i2conomy/test/core.clj

This file was deleted.

14 changes: 14 additions & 0 deletions test/i2conomy/test/mint.clj
@@ -0,0 +1,14 @@
(ns i2conomy.test.mint
(:use [i2conomy.mint] :reload)
(:use [clojure.test]))

(deftest no-payments
(do
(reset-all!)
(is (= 0 (count @transfers)))))

(deftest single-payment
(do
(reset-all!)
(pay "alice" "bob" "alice" 100 "groceries")
(is (= 1 (count @transfers)))))

0 comments on commit 5a3c418

Please sign in to comment.