2019-12-28 11:41:54 +03:00
|
|
|
import net.ftp
|
2019-12-27 21:08:44 +03:00
|
|
|
|
2021-01-26 17:43:10 +03:00
|
|
|
fn test_ftp_cleint() {
|
|
|
|
$if !network ? {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// NB: this function makes network calls to external servers,
|
|
|
|
// that is why it is not a very good idea to run it in CI.
|
|
|
|
// If you want to run it manually, use:
|
|
|
|
// `v -d network vlib/net/ftp/ftp_test.v`
|
|
|
|
ftp_client_test_inside() or { panic(err) }
|
|
|
|
}
|
|
|
|
|
2020-11-15 23:54:47 +03:00
|
|
|
fn ftp_client_test_inside() ? {
|
2021-01-26 17:43:10 +03:00
|
|
|
mut zftp := ftp.new()
|
|
|
|
// eprintln(zftp)
|
2019-12-28 11:41:54 +03:00
|
|
|
defer {
|
2021-01-26 17:43:10 +03:00
|
|
|
zftp.close() or { panic(err) }
|
2019-12-28 11:41:54 +03:00
|
|
|
}
|
2021-01-26 17:43:10 +03:00
|
|
|
connect_result := zftp.connect('ftp.redhat.com') ?
|
2020-11-15 23:54:47 +03:00
|
|
|
assert connect_result
|
2021-01-26 17:43:10 +03:00
|
|
|
login_result := zftp.login('ftp', 'ftp') ?
|
2020-11-15 23:54:47 +03:00
|
|
|
assert login_result
|
2021-01-26 17:43:10 +03:00
|
|
|
pwd := zftp.pwd() ?
|
2019-12-28 15:55:53 +03:00
|
|
|
assert pwd.len > 0
|
2021-01-26 17:43:10 +03:00
|
|
|
zftp.cd('/') or {
|
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dir_list1 := zftp.dir() or {
|
2019-12-28 11:41:54 +03:00
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
assert dir_list1.len > 0
|
2021-01-26 17:43:10 +03:00
|
|
|
zftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/') or {
|
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dir_list2 := zftp.dir() or {
|
2019-12-28 11:41:54 +03:00
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
assert dir_list2.len > 0
|
2021-01-26 17:43:10 +03:00
|
|
|
blob := zftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
|
2019-12-28 11:41:54 +03:00
|
|
|
assert false
|
|
|
|
return
|
2019-12-27 21:08:44 +03:00
|
|
|
}
|
2019-12-28 11:41:54 +03:00
|
|
|
assert blob.len > 0
|
2019-12-27 21:08:44 +03:00
|
|
|
}
|