diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2001-01-25 21:59:39 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2001-01-25 21:59:39 +0000 |
| commit | 7096b8df82eebfe857e0043bc8a853353bd78480 (patch) | |
| tree | f5cdc12138e9526896ff5f8fe9e3ffaa0c47fc0c /test/ftptest.lua | |
| parent | 68f51243b38bf1e32d471e9cc9ddf12a25110e80 (diff) | |
| download | luasocket-7096b8df82eebfe857e0043bc8a853353bd78480.tar.gz luasocket-7096b8df82eebfe857e0043bc8a853353bd78480.tar.bz2 luasocket-7096b8df82eebfe857e0043bc8a853353bd78480.zip | |
Initial revision
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") | ||
