Skip to content

Commit 97d98ac

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

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

bats/tests/utils/rdctl.bats

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
assert_output --partial 'Version:'
18+
}
19+
20+
@test 'rdctl info --output=json' {
21+
run --separate-stderr rdctl info --output=json
22+
assert_success
23+
json=$output
24+
run jq_output .version
25+
assert_success
26+
assert_output --regexp '^v1\.'
27+
output=$json
28+
run jq_output '.["ip-address"]'
29+
assert_success
30+
assert_output --regexp '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
31+
}
32+
33+
@test 'rdctl info --field version' {
34+
run rdctl info --field version
35+
assert_success
36+
assert_output --regexp '^v1\.'
37+
}
38+
39+
@test 'rdctl info --field ip-address' {
40+
run rdctl info --field ip-address
41+
assert_success
42+
if is_windows; then
43+
# On Windows, the IP address should be constant.
44+
assert_output 192.168.127.2
45+
elif is_linux; then
46+
assert_output 192.168.5.15 # qemu slirp
47+
elif is_macos; then
48+
address=$output
49+
if is_true "$(get_setting '.application.adminAccess')"; then
50+
# This is provided by the user's DHCP server
51+
output=$address assert_output --regexp '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'
52+
elif [[ $(get_setting .virtualMachine.type) == vz ]]; then
53+
# macOS Virtualization.Framework NAT
54+
output=$address assert_output --regexp '^192\.168\.205\.'
55+
else
56+
output=$address assert_output 192.168.5.15 # qemu slirp
57+
fi
58+
else
59+
fail 'Unknown OS'
60+
fi
61+
}

0 commit comments

Comments
 (0)