xbps-rindex: add more test-cases and merge issue19 into the generic clean_test.

This commit is contained in:
Juan RP 2013-11-03 10:52:32 +01:00
parent 3602774bc3
commit a8bfc4e9f8
6 changed files with 100 additions and 41 deletions

0
tests/xbps/libxbps/issue18/issue18_test.sh Executable file → Normal file
View File

View File

@ -1,5 +1,5 @@
-include ../../../config.mk
SUBDIRS = common issue19
SUBDIRS = common clean
include ../../../mk/subdir.mk

View File

@ -1,7 +1,7 @@
TOPDIR = ../../../..
-include $(TOPDIR)/config.mk
TEST = issue19_test
TEST = clean_test
include ../Makefile.inc
include $(TOPDIR)/mk/test-shell.mk

View File

@ -0,0 +1,97 @@
#! /usr/bin/env atf-sh
# Test that xbps-rindex(8) -c (clean mode) works as expected.
common_cleanup() {
rm -rf some_repo
}
# 1st test: make sure that nothing is removed if there are no changes.
atf_test_case noremove cleanup
noremove_head() {
atf_set "descr" "xbps-rindex(8) -c: dont removing anything test"
}
noremove_body() {
mkdir -p some_repo pkg_A
cd some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
xbps-rindex -c some_repo
atf_check_equal $? 0
result=$(xbps-query --repository=some_repo -s foo|wc -l)
atf_check_equal ${result} 1
}
noremove_cleanup() {
common_cleanup
}
# 2nd test: make sure that entries are also removed from index-files.
atf_test_case filesclean cleanup
filesclean_head() {
atf_set "descr" "xbps-rindex(8) -c: index-files clean test"
}
filesclean_body() {
mkdir -p some_repo pkg_A
touch -f pkg_A/file00
cd some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
rm *.xbps
cd ..
xbps-rindex -c some_repo
atf_check_equal $? 0
result=$(xbps-query --repository=some_repo -o \*|wc -l)
atf_check_equal ${result} 1
}
filesclean_cleanup() {
common_cleanup
}
# 3rd test: xbps issue #19.
# How to reproduce it:
# Generate pkg foo-1.0_1.
# Add it to the index of a local repo.
# Remove the pkg file from the repo.
# Run xbps-rindex -c on the repo.
atf_test_case issue19 cleanup
issue19_head() {
atf_set "descr" "xbps issue #19 (https://github.com/xtraeme/xbps/issues/19)"
}
issue19_body() {
mkdir -p some_repo
cd some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" .
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
rm some_repo/*.xbps
xbps-rindex -c some_repo
atf_check_equal $? 0
result=$(xbps-query --repository=some_repo -s foo)
test -z "${result}"
atf_check_equal $? 0
}
issue19_cleanup() {
common_cleanup
}
atf_init_test_cases() {
atf_add_test_case noremove
atf_add_test_case filesclean
atf_add_test_case issue19
}

View File

@ -1,4 +1,4 @@
syntax("kyuafile", 1)
test_suite("xbps-rindex")
atf_test_program{name="issue19_test"}
atf_test_program{name="clean_test"}

View File

@ -1,38 +0,0 @@
#! /usr/bin/env atf-sh
# xbps issue #19.
# How to reproduce it:
# Generate pkg foo-1.0_1.
# Add it to the index of a local repo.
# Remove the pkg file from the repo.
# Run xbps-rindex -c on the repo.
atf_test_case issue19
issue19_head() {
atf_set "descr" "xbps issue #19 (https://github.com/xtraeme/xbps/issues/19)"
}
issue19_body() {
mkdir -p some_repo
cd some_repo
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" .
atf_check_equal $? 0
xbps-rindex -a *.xbps
atf_check_equal $? 0
cd ..
rm some_repo/*.xbps
xbps-rindex -c some_repo
atf_check_equal $? 0
result=$(xbps-query --repository=some_repo -s foo)
test -z "${result}"
atf_check_equal $? 0
}
issue19_cleanup() {
rm -rf some_repo
}
atf_init_test_cases() {
atf_add_test_case issue19
}