summaryrefslogtreecommitdiff
path: root/tests/basic-test.sh
diff options
context:
space:
mode:
authorRuixin <peter.bao@mail.utoronto.ca>2017-08-31 15:44:35 +0000
committerAtomic Bot <atomic-devel@projectatomic.io>2017-09-01 15:42:50 +0000
commitf07432d4cefcea7fb8c602b9ab78e83236127d8f (patch)
tree26e226ac0fa173deb7fae4fcff29586a204653ec /tests/basic-test.sh
parent12114ce3828936ed170adaa71a4c6e948764b127 (diff)
downloadostree-f07432d4cefcea7fb8c602b9ab78e83236127d8f.tar.gz
checkout: add an extra checkout_overwrite mode
This is for issue projectatomic/rpm-ostree#365, an extra option of overwrite mode is added to the checkout command so that when there is "non-directory" file already exist during checkout, the error will be handled. Some tests are added for regression Closes: #1116 Approved by: cgwalters
Diffstat (limited to 'tests/basic-test.sh')
-rw-r--r--tests/basic-test.sh28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/basic-test.sh b/tests/basic-test.sh
index de4bd445..6b43ca90 100644
--- a/tests/basic-test.sh
+++ b/tests/basic-test.sh
@@ -19,7 +19,7 @@
set -euo pipefail
-echo "1..$((70 + ${extra_basic_tests:-0}))"
+echo "1..$((72 + ${extra_basic_tests:-0}))"
$CMD_PREFIX ostree --version > version.yaml
python -c 'import yaml; yaml.safe_load(open("version.yaml"))'
@@ -469,6 +469,32 @@ assert_file_has_content checkout-test-union-add/union-add-test 'existing file fo
assert_file_has_content checkout-test-union-add/union-add-test2 'another file for union add testing'
echo "ok checkout union add"
+# Create some new files for testing
+cd ${test_tmpdir}
+mkdir disjoint-union-test
+mkdir disjoint-union-test/test_one
+chmod a+w disjoint-union-test/test_one
+echo 'file for add dirs testing' > disjoint-union-test/test_one/test_file
+$OSTREE commit ${COMMIT_ARGS} -b test-disjoint-union --tree=dir=disjoint-union-test
+$OSTREE checkout --disjoint-union test-disjoint-union checkout-test-disjoint-union
+echo "ok adding new directories and new file"
+# Make a new file, and try the checkout again
+echo 'second test file' > disjoint-union-test/test_one/test_second_file
+$OSTREE commit ${COMMIT_ARGS} -b test-disjoint-union --tree=dir=disjoint-union-test
+# Check out the latest commit, should fail due to presence of existing files
+if $OSTREE checkout --disjoint-union test-disjoint-union checkout-test-disjoint-union 2> err.txt; then
+ assert_not_reached "checking out files unexpectedly succeeded!"
+fi
+assert_file_has_content err.txt 'File exists'
+# Verify that Union mode still functions properly
+rm checkout-test-disjoint-union/test_one/test_file
+echo 'file for testing union mode alongwith disjoint-union mode' > checkout-test-disjoint-union/test_one/test_file
+$OSTREE checkout --union test-disjoint-union checkout-test-disjoint-union
+assert_has_file checkout-test-disjoint-union/test_one/test_second_file
+# This shows the file with same name has been successfully overwriten
+assert_file_has_content checkout-test-disjoint-union/test_one/test_file 'file for add dirs testing'
+echo "ok checkout disjoint union"
+
cd ${test_tmpdir}
rm files -rf && mkdir files
mkdir files/worldwritable-dir