Skip to content

Commit

Permalink
Start adding unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Meier committed Nov 27, 2009
1 parent 8190903 commit 7130407
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
5 changes: 2 additions & 3 deletions TODO.markdown
@@ -1,6 +1,5 @@
Todos
=====

* Implement missing decision points and functions. See webmachine's [big HTTP graph](http://bitbucket.org/justin/webmachine/wiki/BigHTTPGraph)
* Add test cases
* Decide on adapter for [ring](http://github.com/mmcgrana/ring)
* Implement decision path for missing resource
* Add more test cases
30 changes: 30 additions & 0 deletions test/test_all.clj
@@ -0,0 +1,30 @@
(ns test-all
(:use compojure-rest)
(:use clojure.test)
(:import java.util.Date))



(deftest test-evaluate-generate
(testing "with simple vaule"
(is (= :v (evaluate-generate :v {}))))
(testing "with constant function"
(is (= :c (evaluate-generate (fn [request] :c) {}))))
(testing "with function"
(is (= :a (evaluate-generate (fn [request] (request :x)) { :x :a})))))

(deftest test-http-date
(testing "with zero-date"
(is (= "Thu, 01 Jan 1970 00:00:00 +0000" (http-date (new Date (long 0)) "UTC")))))


(deftest test-wrap-header
(testing "with simple value"
(is (= { :body "x" :headers { "header" "foo" }}
((wrap-header (fn [req] { :body "x"})
"header" "foo") {}))))
(testing "with function"
(is (= { :body "x" :headers { "header" "foo" }}
((wrap-header (fn [req] { :body "x"})
"header" (fn [req] "foo")) {})))))

0 comments on commit 7130407

Please sign in to comment.