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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
# Error on unset variables
set -u
if [ -n "${ZSH_VERSION-}" ]; then
SHUNIT_PARENT="$0"
setopt shwordsplit ksh_arrays
fi
. ../liquidprompt --no-activate
typeset -a ssh_values remotehost_values ps_outputs values
# Add test cases to these arrays like below
ssh_values+=(
""
)
remotehost_values+=(
"localhost"
)
ps_outputs+=(
"login"
)
values+=(tel)
ssh_values+=(
"localhost 65116 22"
)
remotehost_values+=(
""
)
ps_outputs+=(
"sshd"
)
values+=(ssh)
ssh_values+=(
"localhost 65116 22"
)
remotehost_values+=(
"localhost"
)
ps_outputs+=(
"sshd"
)
values+=(ssh)
ssh_values+=(
""
)
remotehost_values+=(
""
)
ps_outputs+=(
"su"
)
values+=(su)
ssh_values+=(
""
)
remotehost_values+=(
""
)
ps_outputs+=(
"sudo"
)
values+=(su)
ssh_values+=(
""
)
remotehost_values+=(
""
)
ps_outputs+=(
"bash"
)
values+=(lcl)
ssh_values+=(
""
)
remotehost_values+=(
""
)
ps_outputs+=(
"-bash"
)
values+=(lcl)
ssh_values+=(
""
)
remotehost_values+=(
""
)
ps_outputs+=(
""
)
values+=(lcl)
function test_connection {
typeset SSH_CLIENT REMOTEHOST SSH2_CLIENT="" SSH_TTY=""
ps() {
printf '%s\n' "$__ps_output"
}
for (( index=0; index < ${#values[@]}; index++ )); do
SSH_CLIENT=${ssh_values[$index]}
REMOTEHOST=${remotehost_values[$index]}
__ps_output=${ps_outputs[$index]}
_lp_connection
assertEquals "Connection output at index ${index}" "${values[$index]}" "$lp_connection"
done
}
. ./shunit2
|