aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/net/ftp/ftp_test.v
blob: a62316d00c120b0e605f4d59f44b38d6459c6a48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import net.ftp

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) }
}

fn ftp_client_test_inside() ? {
	mut zftp := ftp.new()
	// eprintln(zftp)
	defer {
		zftp.close() or { panic(err) }
	}
	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 {
		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 {
		assert false
		return
	}
	assert dir_list2.len > 0
	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 {
		assert false
		return
	}
	assert blob.len > 0
}