Permalink
Browse files

add simple test

  • Loading branch information...
1 parent 9922546 commit aa1acd585a3e0de34f062f5bcd7b7baad3cd4375 Takahiro Hozumi committed Apr 26, 2012
Showing with 16 additions and 3 deletions.
  1. +16 −3 test/clj_commons_exec/test/core.clj
@@ -1,6 +1,19 @@
(ns clj-commons-exec.test.core
- (:use [clj-commons-exec.core])
+ (:require [clj-commons-exec :as exec])
(:use [clojure.test]))
-(deftest replace-me ;; FIXME: write
- (is false "No tests have been written."))
+(deftest test-sh
+ (is (= @(exec/sh ["cat"] {:in "hello world"})
+ {:exit 0, :out "hello world", :err nil}))
+ (is (= @(exec/sh ["echo" "hello world"])
+ {:exit 0, :out "hello world\n", :err nil}))
+ (is (= @(exec/sh ["echo" "hello world"] {:handle-quoting? true})
+ {:exit 0, :out "\"hello world\"\n", :err nil}))
+ (let [{:keys [exit exception]} @(exec/sh ["sleep" "1"] {:watchdog 100})]
+ (is (= 143 exit))
+ (is exception)))
+
+(deftest test-sh-pipe
+ (is (= (map deref (exec/sh-pipe ["echo" "hello world"] ["cat"]))
+ [{:exit 0, :out nil, :err nil}
+ {:exit 0, :out "hello world\n", :err nil}])))

0 comments on commit aa1acd5

Please sign in to comment.