2019-12-28 11:41:54 +03:00
|
|
|
import net.ftp
|
2019-12-27 21:08:44 +03:00
|
|
|
|
2019-12-28 15:55:53 +03:00
|
|
|
// 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`
|
2020-01-16 20:16:11 +03:00
|
|
|
fn test_ftp_client() {
|
2020-01-16 21:44:16 +03:00
|
|
|
$if !network ? { return }
|
2019-12-27 21:08:44 +03:00
|
|
|
mut ftp := ftp.new()
|
2019-12-28 11:41:54 +03:00
|
|
|
defer {
|
|
|
|
ftp.close()
|
|
|
|
}
|
|
|
|
assert ftp.connect('ftp.redhat.com')
|
2019-12-28 15:55:53 +03:00
|
|
|
assert ftp.login('ftp', 'ftp')
|
2019-12-28 11:41:54 +03:00
|
|
|
pwd := ftp.pwd()
|
2019-12-28 15:55:53 +03:00
|
|
|
assert pwd.len > 0
|
2019-12-28 11:41:54 +03:00
|
|
|
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
|
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
|
|
|
}
|