Skip to content

Instantly share code, notes, and snippets.

@dezza
Created May 17, 2021 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dezza/4b265874d6069cbf34585933f0bb602d to your computer and use it in GitHub Desktop.
Save dezza/4b265874d6069cbf34585933f0bb602d to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
assertequal () {
(( testcount=testcount+1 ))
if [ "$1" = "$2" ]; then
echo "${testcount} PASS: $3"
else
echo "${testcount} FAIL: expected output failed"
fi
}
testcount=0
read -r -d '' assert_output <<'EOF'
ssh_keys=() array not set
ssh_keys_init variable not set
EOF
test=$(zsh -f keychain.zsh)
assertequal $test $assert_output "ssh_keys, ssh_keys_init not set"
test=$(ssh_keys_init=lazy zsh -f keychain.zsh)
read -r -d '' assert_output <<'EOF'
ssh_keys=() array not set
EOF
unset ssh_keys_init
assertequal $test $assert_output "ssh_keys not set"
test=$(ssh_keys=\(test\) zsh -f keychain.zsh)
read -r -d '' assert_output <<'EOF'
ssh_keys_init variable not set
EOF
unset ssh_keys
assertequal $test $assert_output "ssh_keys_init not set"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment