diff --git a/tests/xbps/xbps-rindex/Kyuafile b/tests/xbps/xbps-rindex/Kyuafile index 149df6f4b..15b87e552 100644 --- a/tests/xbps/xbps-rindex/Kyuafile +++ b/tests/xbps/xbps-rindex/Kyuafile @@ -4,3 +4,4 @@ test_suite("xbps-rindex") atf_test_program{name="add_test"} atf_test_program{name="clean_test"} atf_test_program{name="remove_test"} +atf_test_program{name="unindex_test"} diff --git a/tests/xbps/xbps-rindex/Makefile b/tests/xbps/xbps-rindex/Makefile index ca28e3ad3..477200729 100644 --- a/tests/xbps/xbps-rindex/Makefile +++ b/tests/xbps/xbps-rindex/Makefile @@ -1,7 +1,7 @@ TOPDIR = ../../.. -include $(TOPDIR)/config.mk -TESTSHELL = add_test clean_test remove_test +TESTSHELL = add_test clean_test remove_test unindex_test TESTSSUBDIR = xbps/xbps-rindex EXTRA_FILES = Kyuafile diff --git a/tests/xbps/xbps-rindex/unindex_test.sh b/tests/xbps/xbps-rindex/unindex_test.sh new file mode 100644 index 000000000..9962b27c9 --- /dev/null +++ b/tests/xbps/xbps-rindex/unindex_test.sh @@ -0,0 +1,126 @@ +#! /usr/bin/env atf-sh +# Test that xbps-rindex(8) -R (remove mode) works as expected. + +atf_test_case remove_same + +remove_same_head() { + atf_set "descr" "xbps-rindex(8) -R: test removing indexed version" +} + +remove_same_body() { + mkdir -p some_repo pkg_A pkg_B pkg_C + cd some_repo + xbps-create -A noarch -n foo-a-1.0_1 -s "foo pkg a" ../pkg_A + atf_check_equal $? 0 + xbps-create -A noarch -n foo-b-1.0_1 -s "foo pkg b" ../pkg_B + atf_check_equal $? 0 + xbps-create -A noarch -n foo-c-1.0_1 -s "foo pkg c" ../pkg_C + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')" + expected="[-] foo-a-1.0_1 foo pkg a +[-] foo-b-1.0_1 foo pkg b +[-] foo-c-1.0_1 foo pkg c" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 + xbps-rindex -R $PWD/some_repo/foo-a-1.0_1.noarch.xbps $PWD/some_repo/foo-c-1.0_1.noarch.xbps + atf_check_equal $? 0 + result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')" + expected="[-] foo-b-1.0_1 foo pkg b" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 +} + +atf_test_case remove_newer + +remove_newer_head() { + atf_set "descr" "xbps-rindex(8) -R: test removing newer version" +} + +remove_newer_body() { + mkdir -p some_repo pkg_A-2 pkg_A-1.0 + cd some_repo + xbps-create -A noarch -n foo-a-2_1 -s "foo pkg a" ../pkg_A-2 + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')" + expected="[-] foo-a-2_1 foo pkg a" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 + cd some_repo + xbps-create -A noarch -n foo-a-1.0_1 -s "foo pkg a" ../pkg_A-1.0 + atf_check_equal $? 0 + cd .. + xbps-rindex -R $PWD/some_repo/foo-a-1.0_1.noarch.xbps + atf_check_equal $? 0 + result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')" + expected="" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 +} + + +atf_test_case remove_not_indexed + +remove_not_indexed_head() { + atf_set "descr" "xbps-rindex(8) -R: force remove test" +} + +remove_not_indexed_body() { + mkdir -p some_repo pkg_A + cd some_repo + xbps-create -A noarch -n foo-a-1.0_1 -s "foo pkg a" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')" + expected="[-] foo-a-1.0_1 foo pkg a" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 + xbps-rindex -R $PWD/some_repo/removed-earlier-1_1.noarch.xbps + atf_check_equal $? 0 + result="$(xbps-query -r root -C empty.conf --repository=some_repo -s '')" + rv=0 + if [ "$result" != "$expected" ]; then + echo "result: $result" + echo "expected: $expected" + rv=1 + fi + atf_check_equal $rv 0 +} + +atf_init_test_cases() { + atf_add_test_case remove_same + atf_add_test_case remove_newer + atf_add_test_case remove_not_indexed +}