factor/basis/ftp/server/server-tests.factor

52 lines
1.3 KiB
Factor
Raw Normal View History

2009-02-18 16:29:06 -05:00
USING: calendar ftp.server io.encodings.ascii io.files
io.files.temp io.files.unique namespaces threads tools.test
kernel io.servers ftp.client accessors urls
io.pathnames io.directories sequences fry io.backend
continuations ;
FROM: ftp.client => ftp-get ;
2009-02-18 16:29:06 -05:00
IN: ftp.server.tests
CONSTANT: test-file-contents "Files are so boring anymore."
2009-02-18 16:29:06 -05:00
: create-test-file ( -- path )
test-file-contents
"ftp.server" "test" unique-file
[ ascii set-file-contents ] [ normalize-path ] bi ;
2009-02-18 16:29:06 -05:00
: test-ftp-server ( quot -- )
[
'[
"." 0 <ftp-server> [
"ftp://localhost" >url insecure-addr set-url-addr
"ftp" >>protocol
create-test-file >>path
@
] with-threaded-server
] cleanup-unique-directory
] with-temp-directory ; inline
2009-02-18 16:29:06 -05:00
{ t }
2009-02-18 16:29:06 -05:00
[
[
[
[
[ ftp-get ]
[ path>> file-name ascii file-contents ] bi
] cleanup-unique-directory
] with-temp-directory
2009-02-18 16:29:06 -05:00
] test-ftp-server test-file-contents =
] unit-test
[
2009-02-18 16:29:06 -05:00
[
"/" >>path
[
[
[ ftp-get ]
[ path>> file-name ascii file-contents ] bi
] cleanup-unique-directory
] with-temp-directory
2009-02-18 16:29:06 -05:00
] test-ftp-server test-file-contents =
] must-fail