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

48 lines
1.2 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.unique namespaces threads tools.test kernel
io.servers.connection 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" make-unique-file
[ ascii set-file-contents ] [ normalize-path ] bi ;
2009-02-18 16:29:06 -05:00
: test-ftp-server ( quot -- )
'[
current-temporary-directory get
0 <ftp-server> [
insecure-port
2009-02-18 16:29:06 -05:00
<url>
swap >>port
"ftp" >>protocol
"localhost" >>host
create-test-file >>path
@
] with-threaded-server
] cleanup-unique-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-working-directory
2009-02-18 16:29:06 -05:00
] test-ftp-server test-file-contents =
] unit-test
[
[
"/" >>path
[
2009-02-18 16:29:06 -05:00
[ ftp-get ] [ path>> file-name ascii file-contents ] bi
] cleanup-unique-working-directory
2009-02-18 16:29:06 -05:00
] test-ftp-server test-file-contents =
] must-fail