Initial revision
This commit is contained in:
parent
68f51243b3
commit
7096b8df82
6 changed files with 191 additions and 0 deletions
33
test/ftptest.lua
Normal file
33
test/ftptest.lua
Normal file
|
@ -0,0 +1,33 @@
|
|||
assert(dofile("../lua/ftp.lua"))
|
||||
assert(dofile("auxiliar.lua"))
|
||||
|
||||
pdir = "/home/i/diego/public/html/luasocket/test/"
|
||||
ldir = "/home/luasocket/"
|
||||
adir = "/home/ftp/test/"
|
||||
|
||||
-- needs an accound luasocket:password
|
||||
-- and a copy of /home/i/diego/public/html/luasocket/test in ~ftp/test
|
||||
|
||||
print("testing authenticated upload")
|
||||
bf = readfile(pdir .. "index.html")
|
||||
e = ftp_put("ftp://luasocket:password@localhost/index.html", bf, "b")
|
||||
assert(not e, e)
|
||||
assert(compare(ldir .. "index.html", bf), "files differ")
|
||||
remove(ldir .. "index.html")
|
||||
|
||||
print("testing authenticated download")
|
||||
f, e = ftp_get("ftp://luasocket:password@localhost/test/index.html", "b")
|
||||
assert(f, e)
|
||||
assert(compare(pdir .. "index.html", f), "files differ")
|
||||
|
||||
print("testing anonymous download")
|
||||
f, e = ftp_get("ftp://localhost/test/index.html", "b")
|
||||
assert(f, e)
|
||||
assert(compare(adir .. "index.html", f), "files differ")
|
||||
|
||||
print("testing directory listing")
|
||||
f, e = ftp_get("ftp://localhost/test/")
|
||||
assert(f, e)
|
||||
assert(f == "index.html\r\n", "files differ")
|
||||
|
||||
print("passed all tests")
|
Loading…
Add table
Add a link
Reference in a new issue