]> gitweb.factorcode.org Git - factor.git/blob - basis/ftp/server/server-tests.factor
56b21097e0cf23dc3cf3a2b1b6384240182fe86d
[factor.git] / basis / ftp / server / server-tests.factor
1 USING: calendar ftp.server io.encodings.ascii io.files
2 io.files.unique namespaces threads tools.test kernel
3 io.servers ftp.client accessors urls
4 io.pathnames io.directories sequences fry io.backend
5 continuations ;
6 FROM: ftp.client => ftp-get ;
7 IN: ftp.server.tests
8
9 CONSTANT: test-file-contents "Files are so boring anymore."
10
11 : create-test-file ( -- path )
12     test-file-contents
13     "ftp.server" "test" make-unique-file
14     [ ascii set-file-contents ] [ normalize-path ] bi ;
15
16 : test-ftp-server ( quot -- )
17     '[
18         current-temporary-directory get
19         0 <ftp-server> [
20             "ftp://localhost" >url insecure-addr set-url-addr
21                 "ftp" >>protocol
22                 create-test-file >>path
23                 @
24         ] with-threaded-server
25     ] cleanup-unique-directory ; inline
26
27 [ t ]
28 [
29     [
30         [
31             [ ftp-get ] [ path>> file-name ascii file-contents ] bi
32         ] cleanup-unique-working-directory
33     ] test-ftp-server test-file-contents =
34 ] unit-test
35
36 [
37
38     [
39         "/" >>path
40         [
41             [ ftp-get ] [ path>> file-name ascii file-contents ] bi
42         ] cleanup-unique-working-directory
43     ] test-ftp-server test-file-contents =
44 ] must-fail