2019-12-28 09:41:54 +01:00
|
|
|
import net.ftp
|
2019-12-27 19:08:44 +01:00
|
|
|
|
2021-01-26 15:43:10 +01: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:
|
2021-02-02 08:22:52 +01:00
|
|
|
// `v -d network vlib/net/ftp/ftp_test.v`
|
2021-01-26 15:43:10 +01:00
|
|
|
ftp_client_test_inside() or { panic(err) }
|
|
|
|
}
|
|
|
|
|
2020-11-15 21:54:47 +01:00
|
|
|
fn ftp_client_test_inside() ? {
|
2021-01-26 15:43:10 +01:00
|
|
|
mut zftp := ftp.new()
|
2021-02-02 08:22:52 +01:00
|
|
|
// eprintln(zftp)
|
2019-12-28 09:41:54 +01:00
|
|
|
defer {
|
2021-01-26 15:43:10 +01:00
|
|
|
zftp.close() or { panic(err) }
|
2019-12-28 09:41:54 +01:00
|
|
|
}
|
2021-01-26 15:43:10 +01:00
|
|
|
connect_result := zftp.connect('ftp.redhat.com') ?
|
2020-11-15 21:54:47 +01:00
|
|
|
assert connect_result
|
2021-01-26 15:43:10 +01:00
|
|
|
login_result := zftp.login('ftp', 'ftp') ?
|
2020-11-15 21:54:47 +01:00
|
|
|
assert login_result
|
2021-01-26 15:43:10 +01:00
|
|
|
pwd := zftp.pwd() ?
|
2019-12-28 13:55:53 +01:00
|
|
|
assert pwd.len > 0
|
2021-01-26 15:43:10 +01:00
|
|
|
zftp.cd('/') or {
|
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dir_list1 := zftp.dir() or {
|
2019-12-28 09:41:54 +01:00
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
assert dir_list1.len > 0
|
2021-01-26 15:43:10 +01:00
|
|
|
zftp.cd('/suse/linux/enterprise/11Server/en/SAT-TOOLS/SRPMS/') or {
|
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
dir_list2 := zftp.dir() or {
|
2019-12-28 09:41:54 +01:00
|
|
|
assert false
|
|
|
|
return
|
|
|
|
}
|
|
|
|
assert dir_list2.len > 0
|
2021-02-02 08:22:52 +01:00
|
|
|
assert dir_list2.contains('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm')
|
2021-01-26 15:43:10 +01:00
|
|
|
blob := zftp.get('katello-host-tools-3.3.5-8.sles11_4sat.src.rpm') or {
|
2019-12-28 09:41:54 +01:00
|
|
|
assert false
|
|
|
|
return
|
2019-12-27 19:08:44 +01:00
|
|
|
}
|
2019-12-28 09:41:54 +01:00
|
|
|
assert blob.len > 0
|
2019-12-27 19:08:44 +01:00
|
|
|
}
|