diff options
Diffstat (limited to 'test/ftptest.lua')
-rw-r--r-- | test/ftptest.lua | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ftptest.lua b/test/ftptest.lua new file mode 100644 index 0000000..85dc16b --- /dev/null +++ b/test/ftptest.lua | |||
@@ -0,0 +1,33 @@ | |||
1 | assert(dofile("../lua/ftp.lua")) | ||
2 | assert(dofile("auxiliar.lua")) | ||
3 | |||
4 | pdir = "/home/i/diego/public/html/luasocket/test/" | ||
5 | ldir = "/home/luasocket/" | ||
6 | adir = "/home/ftp/test/" | ||
7 | |||
8 | -- needs an accound luasocket:password | ||
9 | -- and a copy of /home/i/diego/public/html/luasocket/test in ~ftp/test | ||
10 | |||
11 | print("testing authenticated upload") | ||
12 | bf = readfile(pdir .. "index.html") | ||
13 | e = ftp_put("ftp://luasocket:password@localhost/index.html", bf, "b") | ||
14 | assert(not e, e) | ||
15 | assert(compare(ldir .. "index.html", bf), "files differ") | ||
16 | remove(ldir .. "index.html") | ||
17 | |||
18 | print("testing authenticated download") | ||
19 | f, e = ftp_get("ftp://luasocket:password@localhost/test/index.html", "b") | ||
20 | assert(f, e) | ||
21 | assert(compare(pdir .. "index.html", f), "files differ") | ||
22 | |||
23 | print("testing anonymous download") | ||
24 | f, e = ftp_get("ftp://localhost/test/index.html", "b") | ||
25 | assert(f, e) | ||
26 | assert(compare(adir .. "index.html", f), "files differ") | ||
27 | |||
28 | print("testing directory listing") | ||
29 | f, e = ftp_get("ftp://localhost/test/") | ||
30 | assert(f, e) | ||
31 | assert(f == "index.html\r\n", "files differ") | ||
32 | |||
33 | print("passed all tests") | ||