]> gitweb.factorcode.org Git - factor.git/commitdiff
imap: Better errors when not configured.
authorDoug Coleman <doug.coleman@gmail.com>
Thu, 13 Mar 2014 08:24:28 +0000 (03:24 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Thu, 13 Mar 2014 08:24:28 +0000 (03:24 -0500)
extra/imap/imap-tests.factor

index 161b9bafdd08b2b691f870c9428df18433712603..393bcdff37eba4d08d21d73bfecaa388e4ee46a0 100644 (file)
@@ -33,29 +33,37 @@ SYMBOLS: email host password ;
         email get password get login drop
     ] with-stream* ;
 
+ERROR: host-not-set ;
+
+: get-test-host ( -- host )
+    host get dup [ host-not-set throw ] unless ;
+
+: ensure-host ( -- ) get-test-host drop ;
+
 : imap-test ( result quot -- )
+    ensure-host
     '[ imap-login _ with-stream ] unit-test ; inline
 
 [ t ] [
-    host get <imap4ssl> duplex-stream?
+    get-test-host <imap4ssl> duplex-stream?
 ] unit-test
 
 [ t ] [
-    host get <imap4ssl> [ capabilities ] with-stream
+    get-test-host <imap4ssl> [ capabilities ] with-stream
     { "IMAP4rev1" "UNSELECT" "IDLE" "NAMESPACE" "QUOTA" } swap subset?
 ] unit-test
 
 [ "NO" ] [
-    [ host get <imap4ssl> [ "dont@exist.com" "foo" login ] with-stream ]
+    [ get-test-host <imap4ssl> [ "dont@exist.com" "foo" login ] with-stream ]
     [ ind>> ] recover
 ] unit-test
 
 [ "BAD" ] [
-    [ host get <imap4ssl> [ f f login ] with-stream ] [ ind>> ] recover
+    [ get-test-host <imap4ssl> [ f f login ] with-stream ] [ ind>> ] recover
 ] unit-test
 
 [ f ] [
-    host get <imap4ssl> [
+    get-test-host <imap4ssl> [
         email get password get login
     ] with-stream empty?
 ] unit-test