mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 06:04:31 +02:00
Initial revision
This commit is contained in:
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")
|
Reference in New Issue
Block a user