From efb336a23b65a9a2d56889396b13c1757bdaf354 Mon Sep 17 00:00:00 2001 From: Roger Gonzalez Date: Sun, 29 Dec 2019 14:58:33 -0300 Subject: Initial commit --- .../spacefish/tests/__sf_section_pyenv.test.fish | 159 +++++++++++++++++++++ 1 file changed, 159 insertions(+) create mode 100644 .config/fisher/github.com/matchai/spacefish/tests/__sf_section_pyenv.test.fish (limited to '.config/fisher/github.com/matchai/spacefish/tests/__sf_section_pyenv.test.fish') diff --git a/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_pyenv.test.fish b/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_pyenv.test.fish new file mode 100644 index 00000000..b9576800 --- /dev/null +++ b/.config/fisher/github.com/matchai/spacefish/tests/__sf_section_pyenv.test.fish @@ -0,0 +1,159 @@ +source $DIRNAME/spacefish_test_setup.fish + +function setup + spacefish_test_setup + mock pyenv version-name 0 "echo \"3.7.0\"" + mkdir -p /tmp/tmp-spacefish + cd /tmp/tmp-spacefish +end + +function teardown + rm -rf /tmp/tmp-spacefish + if test "$PYENV_VERSION" + set -e PYENV_VERSION + end +end + +test "Prints section when \$PYENV_VERSION is defined" + ( + set PYENV_VERSION 3.7.0 + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Prints section when .python-version is present" + ( + touch /tmp/tmp-spacefish/.python-version + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Prints section when requirements.txt is present" + ( + touch /tmp/tmp-spacefish/requirements.txt + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Prints section when pyproject.toml is present" + ( + touch /tmp/tmp-spacefish/pyproject.toml + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Prints section when a *.py file is present" + ( + touch /tmp/tmp-spacefish/testfile.py + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Doesn't print the section when requirements.txt and *.py aren't present" + () = (__sf_section_pyenv) +end + +test "Changing SPACEFISH_PYENV_SYMBOL changes the displayed character" + ( + touch /tmp/tmp-spacefish/requirements.txt + set SPACEFISH_PYENV_SYMBOL "路 " + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "路 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Changing SPACEFISH_PYENV_PREFIX changes the character prefix" + ( + touch /tmp/tmp-spacefish/requirements.txt + set sf_exit_code 0 + set SPACEFISH_PYENV_PREFIX 路 + + set_color --bold + echo -n "路" + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n " " + set_color normal + ) = (__sf_section_pyenv) +end + +test "Changing SPACEFISH_PYENV_SUFFIX changes the character suffix" + ( + touch /tmp/tmp-spacefish/requirements.txt + set sf_exit_code 0 + set SPACEFISH_PYENV_SUFFIX 路 + + set_color --bold + echo -n "via " + set_color normal + set_color --bold yellow + echo -n "馃悕 3.7.0" + set_color normal + set_color --bold + echo -n "路" + set_color normal + ) = (__sf_section_pyenv) +end + +test "doesn't display the section when SPACEFISH_PYENV_SHOW is set to \"false\"" + ( + touch /tmp/tmp-spacefish/requirements.txt + set SPACEFISH_PYENV_SHOW false + ) = (__sf_section_pyenv) +end -- cgit v1.2.3