1
0
Fork 0
mirror of synced 2024-11-14 05:28:58 -05:00
tpm/tests/test_plugin_clean.sh

65 lines
1.5 KiB
Bash
Raw Normal View History

2015-05-26 23:46:15 -04:00
#!/usr/bin/env bash
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
2015-07-31 19:54:34 -04:00
TPM_DIR="$PWD"
PLUGINS_DIR="$HOME/.tmux/plugins"
2015-05-26 23:46:15 -04:00
2015-08-01 16:12:07 -04:00
source "$CURRENT_DIR/helpers/helpers.sh"
source "$CURRENT_DIR/helpers/tpm.sh"
2015-05-26 23:46:15 -04:00
manually_install_the_plugin() {
2015-07-31 19:54:34 -04:00
rm -rf "$PLUGINS_DIR"
mkdir -p "$PLUGINS_DIR"
cd "$PLUGINS_DIR"
2015-05-26 23:46:15 -04:00
git clone --quiet https://github.com/tmux-plugins/tmux-example-plugin
}
# TMUX KEY-BINDING TESTS
test_plugin_uninstallation_via_tmux_key_binding() {
2015-05-26 23:46:15 -04:00
set_tmux_conf_helper <<- HERE
2015-07-31 19:54:34 -04:00
run-shell "$TPM_DIR/tpm"
2015-05-26 23:46:15 -04:00
HERE
manually_install_the_plugin
2015-07-31 19:54:34 -04:00
"$CURRENT_DIR/expect_successful_clean_plugins" ||
fail_helper "[key-binding] clean fails"
teardown_helper
}
# SCRIPT TESTS
test_plugin_uninstallation_via_script() {
set_tmux_conf_helper <<- HERE
run-shell "$TPM_DIR/tpm"
HERE
manually_install_the_plugin
script_run_helper "$TPM_DIR/bin/clean_plugins" '"tmux-example-plugin" clean success' ||
fail_helper "[script] plugin cleaning fails"
teardown_helper
}
test_unsuccessful_plugin_uninstallation_via_script() {
set_tmux_conf_helper <<- HERE
run-shell "$TPM_DIR/tpm"
HERE
manually_install_the_plugin
chmod 000 "$PLUGINS_DIR/tmux-example-plugin" # disable directory deletion
local expected_exit_code=1
script_run_helper "$TPM_DIR/bin/clean_plugins" '"tmux-example-plugin" clean fail' "$expected_exit_code" ||
fail_helper "[script] unsuccessful plugin cleaning doesn't fail"
chmod 755 "$PLUGINS_DIR/tmux-example-plugin" # enable directory deletion
2015-05-26 23:46:15 -04:00
teardown_helper
}
2015-08-01 12:06:19 -04:00
run_tests