From 13051d01683d5433de992ad7890f0f9d2b9b387a Mon Sep 17 00:00:00 2001 From: Bruno Pinto Date: Fri, 9 Jan 2015 21:15:19 -0200 Subject: [PATCH] oh-my-fish.fish tests --- test/helper.fish | 7 ++++ test/test_oh-my-fish.fish | 80 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 test/helper.fish create mode 100644 test/test_oh-my-fish.fish diff --git a/test/helper.fish b/test/helper.fish new file mode 100644 index 0000000..0ac6202 --- /dev/null +++ b/test/helper.fish @@ -0,0 +1,7 @@ +set -l fish_tank /usr/local/share/fish-tank/tank.fish +if not test -e $fish_tank + echo 'error: fish-tank is required to run these tests (https://github.com/terlar/fish-tank)' + exit 1 +end + +source $fish_tank diff --git a/test/test_oh-my-fish.fish b/test/test_oh-my-fish.fish new file mode 100644 index 0000000..2f7e6aa --- /dev/null +++ b/test/test_oh-my-fish.fish @@ -0,0 +1,80 @@ +function suite_oh-my-fish + function setup + set -g fish_custom_bak $fish_custom + set -g fish_function_path_bak $fish_function_path + set -g fish_plugins_bak $fish_plugins + end + + function teardown + set fish_custom $fish_custom_bak + set fish_function_path $fish_function_path_bak + set fish_plugins $fish_plugins_bak + end + + # + # tests + # + + function test_default_custom_folder + set -e fish_custom + load_oh_my_fish + assert_equal ~/.oh-my-fish/custom $fish_custom + end + + function test_custom_folder + set fish_custom /tmp + load_oh_my_fish + assert_equal /tmp $fish_custom + end + + function test_load_custom_files + set fish_custom /tmp + echo 'set -gx TEST_LOAD_CUSTOM_FILE test_load' > $fish_custom/test.load + load_oh_my_fish + assert_equal test_load $TEST_LOAD_CUSTOM_FILE + end + + function test_oh_my_fish_functions + remove_from_array "$fish_path/functions/" fish_function_path + load_oh_my_fish + assert_includes $fish_path/functions/ $fish_function_path + end + + function test_oh_my_fish_plugins + remove_from_array "$fish_path/plugins/z" fish_function_path + set fish_plugins z + load_oh_my_fish + assert_includes $fish_path/plugins/z $fish_function_path + end + + function test_oh_my_fish_themes + remove_from_array "$fish_path/themes/l" fish_function_path + set fish_theme l + load_oh_my_fish + assert_includes $fish_path/themes/l $fish_function_path + end + + # + # helper functions + # + + function load_oh_my_fish + . $fish_path/oh-my-fish.fish + end + + function remove_from_array + set -l element $argv[1] + + for i in (seq (count $$argv[2])) + if test $$argv[2][$i] = $element + set -e $argv[2][$i] + break + end + end + end +end + +if not set -q tank_running + source (dirname (status -f))/helper.fish + tank_run +end