Skip to content

Commit 55efafc

Browse files
committed
BATS: add test for rdctl info
Signed-off-by: Mark Yen <[email protected]>
1 parent 7bece4e commit 55efafc

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

bats/tests/utils/rdctl.bats

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
load '../helpers/load'
2+
3+
# Verify various operations of `rdctl`
4+
5+
@test 'factory reset' {
6+
factory_reset
7+
}
8+
9+
@test 'start Rancher Desktop' {
10+
start_container_engine
11+
wait_for_container_engine
12+
}
13+
14+
@test 'rdctl info' {
15+
run --separate-stderr rdctl info
16+
assert_success
17+
json=$output
18+
run jq_output .version
19+
assert_success
20+
assert_output --regexp '^v1\.'
21+
output=$json
22+
run jq_output '.["ip-address"]'
23+
assert_success
24+
assert_output --regexp .
25+
}
26+
27+
@test 'rdctl info --field version' {
28+
run rdctl info --field version
29+
assert_success
30+
assert_output --regexp '^v1\.'
31+
}
32+
33+
@test 'rdctl info --field ip-address' {
34+
run rdctl info --field ip-address
35+
assert_success
36+
if is_windows; then
37+
# On Windows, the IP address should be constant.
38+
assert_output 192.168.127.2
39+
elif is_linux; then
40+
assert_output 192.168.5.15 # qemu slirp
41+
elif is_macos; then
42+
address=$output
43+
if is_true "$(get_setting '.application.adminAccess')"; then
44+
# This is provided by the user's DHCP server
45+
output=$address assert_output --regexp '^\d+\.\d+\.\d+\.\d+$'
46+
elif [[ $(get_setting .virtualMachine.type) == vz ]]; then
47+
# macOS Virtualization.Framework NAT
48+
output=$address assert_output --regexp '^192\.168\.205\.'
49+
else
50+
output=$address assert_output 192.168.5.15 # qemu slirp
51+
fi
52+
else
53+
fail 'Unknown OS'
54+
fi
55+
}

0 commit comments

Comments
 (0)