From 79bd3441eb1b50f1d83b2e17a5510f4cc796431c Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Tue, 22 Jan 2019 22:12:05 -0800 Subject: [PATCH] Add test for mv non-empty directory --- test/integration-test-main.sh | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/integration-test-main.sh b/test/integration-test-main.sh index 075a37a..df2505a 100755 --- a/test/integration-test-main.sh +++ b/test/integration-test-main.sh @@ -108,7 +108,7 @@ function test_mv_file { rm_test_file $ALT_TEST_TEXT_FILE } -function test_mv_directory { +function test_mv_empty_directory { describe "Testing mv directory function ..." if [ -e $TEST_DIR ]; then echo "Unexpected, this file/directory exists: ${TEST_DIR}" @@ -118,7 +118,6 @@ function test_mv_directory { mk_test_dir mv ${TEST_DIR} ${TEST_DIR}_rename - if [ ! -d "${TEST_DIR}_rename" ]; then echo "Directory ${TEST_DIR} was not renamed" return 1 @@ -131,6 +130,30 @@ function test_mv_directory { fi } +function test_mv_nonempty_directory { + describe "Testing mv directory function ..." + if [ -e $TEST_DIR ]; then + echo "Unexpected, this file/directory exists: ${TEST_DIR}" + return 1 + fi + + mk_test_dir + + touch ${TEST_DIR}/file + + mv ${TEST_DIR} ${TEST_DIR}_rename + if [ ! -d "${TEST_DIR}_rename" ]; then + echo "Directory ${TEST_DIR} was not renamed" + return 1 + fi + + rm -r ${TEST_DIR}_rename + if [ -e "${TEST_DIR}_rename" ]; then + echo "Could not remove the test directory, it still exists: ${TEST_DIR}_rename" + return 1 + fi +} + function test_redirects { describe "Testing redirects ..." @@ -493,7 +516,8 @@ function add_all_tests { add_tests test_truncate_file add_tests test_truncate_empty_file add_tests test_mv_file - add_tests test_mv_directory + add_tests test_mv_empty_directory + add_tests test_mv_nonempty_directory add_tests test_redirects add_tests test_mkdir_rmdir add_tests test_chmod