mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ftp: flatten tests
This commit is contained in:
parent
72acbad3f0
commit
e02d6a3b04
@ -1,57 +1,35 @@
|
||||
module main
|
||||
|
||||
|
||||
import ftp
|
||||
import net.ftp
|
||||
|
||||
fn test_all() {
|
||||
mut ftp := ftp.new()
|
||||
|
||||
// ftp.rediris.org
|
||||
connected := ftp.connect('ftp.redhat.com')
|
||||
assert connected
|
||||
if connected {
|
||||
println("connected")
|
||||
|
||||
loggedin := ftp.login('ftp','ftp')
|
||||
assert loggedin
|
||||
if loggedin {
|
||||
println('logged-in')
|
||||
|
||||
pwd := ftp.pwd()
|
||||
println('pwd: $pwd')
|
||||
|
||||
ftp.cd('/')
|
||||
|
||||
folder := ftp.dir() or {
|
||||
eprintln('cannot list folder')
|
||||
return
|
||||
}
|
||||
for file in folder {
|
||||
println(file)
|
||||
}
|
||||
|
||||
ftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/')
|
||||
|
||||
dir_list := ftp.dir() or {
|
||||
eprintln('cannot list folder')
|
||||
return
|
||||
}
|
||||
|
||||
assert dir_list.len > 5
|
||||
println('$dir_list.len files:')
|
||||
for file in dir_list {
|
||||
println('$file')
|
||||
}
|
||||
|
||||
blob := ftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
|
||||
eprintln("couldn't download it")
|
||||
return
|
||||
}
|
||||
|
||||
assert blob.len > 1024
|
||||
|
||||
println('downloaded $blob.len bytes')
|
||||
}
|
||||
defer {
|
||||
ftp.close()
|
||||
}
|
||||
|
||||
assert ftp.connect('ftp.redhat.com')
|
||||
assert ftp.login('ftp','ftp')
|
||||
|
||||
pwd := ftp.pwd()
|
||||
|
||||
ftp.cd('/')
|
||||
dir_list1 := ftp.dir() or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
assert dir_list1.len > 0
|
||||
|
||||
ftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/')
|
||||
dir_list2 := ftp.dir() or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
assert dir_list2.len > 0
|
||||
|
||||
blob := ftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
assert blob.len > 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user