v/vlib/net/ftp/ftp_test.v

51 lines
1.1 KiB
V
Raw Normal View History

2019-12-28 09:41:54 +01:00
import net.ftp
2019-12-27 19:08:44 +01:00
fn test_ftp_cleint() {
$if !network ? {
return
}
// Note: 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`
ftp_client_test_inside() or { panic(err) }
}
fn ftp_client_test_inside() ? {
mut zftp := ftp.new()
2021-02-02 08:22:52 +01:00
// eprintln(zftp)
2019-12-28 09:41:54 +01:00
defer {
zftp.close() or { panic(err) }
2019-12-28 09:41:54 +01:00
}
connect_result := zftp.connect('ftp.redhat.com')?
assert connect_result
login_result := zftp.login('ftp', 'ftp')?
assert login_result
pwd := zftp.pwd()?
assert pwd.len > 0
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
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')
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
}