]> gitweb.factorcode.org Git - factor.git/blob - basis/ftp/server/server-tests.factor
Squashed commit of the following:
[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             insecure-port
21             <url>
22                 swap >>port
23                 "ftp" >>protocol
24                 "localhost" >>host
25                 create-test-file >>path
26                 @
27         ] with-threaded-server
28     ] cleanup-unique-directory ; inline
29
30 [ t ]
31 [
32     [
33         [
34             [ ftp-get ] [ path>> file-name ascii file-contents ] bi
35         ] cleanup-unique-working-directory
36     ] test-ftp-server test-file-contents =
37 ] unit-test
38
39 [
40     
41     [
42         "/" >>path
43         [
44             [ ftp-get ] [ path>> file-name ascii file-contents ] bi
45         ] cleanup-unique-working-directory
46     ] test-ftp-server test-file-contents =
47 ] must-fail