Skip to content

Commit

Permalink
Test xbps-rindex -R
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocimier committed Apr 10, 2019
1 parent c4cf0d2 commit 88d9eee
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/xbps/xbps-rindex/Kyuafile
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
2 changes: 1 addition & 1 deletion tests/xbps/xbps-rindex/Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
169 changes: 169 additions & 0 deletions tests/xbps/xbps-rindex/unindex_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
#! /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
cd some_repo
xbps-rindex -R $PWD $PWD/foo-a-1.0_1.noarch.xbps $PWD/foo-c-1.0_1.noarch.xbps
atf_check_equal $? 0
cd ..
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_older

remove_older_head() {
atf_set "descr" "xbps-rindex(8) -R: test removing older version"
}

remove_older_body() {
mkdir -p some_repo pkg_A-2.0 pkg_A-1.0
cd some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A-1.0
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-1.0_1 foo pkg"
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-2.0_1 -s "foo pkg" ../pkg_A-2.0
atf_check_equal $? 0
xbps-rindex -R $PWD $PWD/foo-2.0_1.noarch.xbps
atf_check_equal $? 0
cd ..
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_newer_noop

remove_newer_noop_head() {
atf_set "descr" "xbps-rindex(8) -R: newer version is not removed"
}

remove_newer_noop_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
xbps-rindex -R $PWD $PWD/foo-a-1.0_1.noarch.xbps $PWD/nonpkg-0.1_1.noarch.xbps
atf_check_equal $? 0
cd ..
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_test_case force_remove

force_remove_head() {
atf_set "descr" "xbps-rindex(8) -R: force remove test"
}

force_remove_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 -Rf $PWD/some_repo foo-a
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_init_test_cases() {
atf_add_test_case remove_same
atf_add_test_case remove_older
atf_add_test_case remove_newer_noop
atf_add_test_case force_remove
}

0 comments on commit 88d9eee

Please sign in to comment.