factor/basis/furnace/auth/providers/db/db-tests.factor

51 lines
1.3 KiB
Factor
Raw Normal View History

USING: furnace.actions
2008-06-16 04:34:17 -04:00
furnace.auth
furnace.auth.login
furnace.auth.providers
furnace.auth.providers.db tools.test
2008-03-06 04:03:07 -05:00
namespaces db db.sqlite db.tuples continuations
io.files io.files.temp io.directories accessors kernel
sequences system ;
IN: furnace.auth.providers.db.tests
2008-06-16 04:34:17 -04:00
<action> "test" <login-realm> realm set
: auth-test-db-name ( -- string )
cpu name>> "auth-test." ".db" surround ;
2008-04-29 22:04:06 -04:00
[ auth-test-db-name temp-file delete-file ] ignore-errors
auth-test-db-name temp-file <sqlite-db> [
2008-03-11 04:39:09 -04:00
user ensure-table
2008-03-11 04:39:09 -04:00
[ t ] [
2008-04-29 22:04:06 -04:00
"slava" <user>
2008-05-01 17:24:50 -04:00
"foobar" >>encoded-password
2008-03-17 05:31:13 -04:00
"slava@factorcode.org" >>email
2008-04-29 22:04:06 -04:00
H{ } clone >>profile
2008-05-01 17:24:50 -04:00
users new-user
2008-03-17 05:31:13 -04:00
username>> "slava" =
2008-03-11 04:39:09 -04:00
] unit-test
[ f ] [
2008-04-29 22:04:06 -04:00
"slava" <user>
H{ } clone >>profile
2008-05-01 17:24:50 -04:00
users new-user
2008-03-11 04:39:09 -04:00
] unit-test
2008-05-01 17:24:50 -04:00
[ f ] [ "fdasf" "slava" check-login >boolean ] unit-test
2008-05-01 17:24:50 -04:00
[ ] [ "foobar" "slava" check-login "user" set ] unit-test
2008-03-17 05:31:13 -04:00
[ t ] [ "user" get >boolean ] unit-test
2008-05-01 17:24:50 -04:00
[ ] [ "user" get "fdasf" >>encoded-password drop ] unit-test
2008-05-01 17:24:50 -04:00
[ ] [ "user" get users update-user ] unit-test
2008-05-01 17:24:50 -04:00
[ t ] [ "fdasf" "slava" check-login >boolean ] unit-test
2008-05-01 17:24:50 -04:00
[ f ] [ "foobar" "slava" check-login >boolean ] unit-test
] with-db