tests: add xbps-fetch tests
Add test cases for xbps-fetch, including testing for: - remote file identical with local file - multiple files fetched - error handling for multiple files fetched
This commit is contained in:
parent
bb98a393c0
commit
c08542ccac
@ -6,6 +6,7 @@ include('libxbps/Kyuafile')
|
||||
include('xbps-alternatives/Kyuafile')
|
||||
include('xbps-checkvers/Kyuafile')
|
||||
include('xbps-create/Kyuafile')
|
||||
include('xbps-fetch/Kyuafile')
|
||||
include('xbps-install/Kyuafile')
|
||||
include('xbps-query/Kyuafile')
|
||||
include('xbps-rindex/Kyuafile')
|
||||
|
@ -1,5 +1,5 @@
|
||||
-include ../../config.mk
|
||||
|
||||
SUBDIRS = common libxbps xbps-alternatives xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex xbps-uhelper xbps-remove xbps-digest
|
||||
SUBDIRS = common libxbps xbps-alternatives xbps-checkvers xbps-create xbps-fetch xbps-install xbps-query xbps-rindex xbps-uhelper xbps-remove xbps-digest
|
||||
|
||||
include ../../mk/subdir.mk
|
||||
|
4
tests/xbps/xbps-fetch/Kyuafile
Normal file
4
tests/xbps/xbps-fetch/Kyuafile
Normal file
@ -0,0 +1,4 @@
|
||||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("xbps-fetch")
|
||||
atf_test_program{name="fetch_test"}
|
8
tests/xbps/xbps-fetch/Makefile
Normal file
8
tests/xbps/xbps-fetch/Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
TOPDIR = ../../..
|
||||
-include $(TOPDIR)/config.mk
|
||||
|
||||
TESTSHELL = fetch_test
|
||||
TESTSSUBDIR = xbps/xbps-fetch
|
||||
EXTRA_FILES = Kyuafile
|
||||
|
||||
include $(TOPDIR)/mk/test.mk
|
83
tests/xbps/xbps-fetch/fetch_test.sh
Executable file
83
tests/xbps/xbps-fetch/fetch_test.sh
Executable file
@ -0,0 +1,83 @@
|
||||
#! /usr/bin/env atf-sh
|
||||
# Test that xbps-fetch works as expected.
|
||||
|
||||
atf_test_case success
|
||||
|
||||
success_head() {
|
||||
atf_set "descr" "xbps-fetch: test successful remote fetch"
|
||||
}
|
||||
|
||||
success_body() {
|
||||
mkdir some_repo
|
||||
touch some_repo/pkg_A
|
||||
xbps-fetch file://$PWD/some_repo/pkg_A
|
||||
atf_check_equal $? 0
|
||||
}
|
||||
|
||||
atf_test_case pkgnotfound
|
||||
|
||||
pkgnotfound_head() {
|
||||
atf_set "descr" "xbps-fetch: test remote package not found"
|
||||
}
|
||||
|
||||
pkgnotfound_body() {
|
||||
xbps-fetch file://$PWD/nonexistant
|
||||
atf_check_equal $? 1
|
||||
}
|
||||
|
||||
atf_test_case identical
|
||||
|
||||
identical_head() {
|
||||
atf_set "descr" "xbps-fetch: test fetching identical file from remote"
|
||||
}
|
||||
|
||||
identical_body() {
|
||||
mkdir some_repo
|
||||
echo 'content' > some_repo/pkg_A
|
||||
echo 'content' > pkg_A
|
||||
output=$(xbps-fetch file://$PWD/some_repo/pkg_A 2>&1)
|
||||
atf_check_equal $? 0
|
||||
atf_check_equal "$output" "file://$PWD/some_repo/pkg_A: file is identical with remote."
|
||||
}
|
||||
|
||||
atf_test_case multiple_success
|
||||
|
||||
multiple_success_head() {
|
||||
atf_set "descr" "xbps-fetch: test fetching multiple remote files"
|
||||
}
|
||||
|
||||
multiple_success_body() {
|
||||
mkdir some_repo
|
||||
touch some_repo/pkg_A some_repo/pkg_B
|
||||
xbps-fetch file://$PWD/some_repo/pkg_A file://$PWD/some_repo/pkg_B
|
||||
atf_check_equal $? 0
|
||||
test -f pkg_A
|
||||
atf_check_equal $? 0
|
||||
test -f pkg_B
|
||||
atf_check_equal $? 0
|
||||
}
|
||||
|
||||
atf_test_case multiple_notfound
|
||||
|
||||
multiple_notfound_head() {
|
||||
atf_set "descr" "xbps-fetch: test fetching multiple remote files, with one not found"
|
||||
}
|
||||
|
||||
multiple_notfound_body() {
|
||||
mkdir some_repo
|
||||
touch some_repo/pkg_A
|
||||
xbps-fetch file://$PWD/some_repo/nonexistant file://$PWD/some_repo/pkg_A
|
||||
atf_check_equal $? 1
|
||||
test -f pkg_A
|
||||
atf_check_equal $? 0
|
||||
test -f nonexistant
|
||||
atf_check_equal $? 1
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case success
|
||||
atf_add_test_case pkgnotfound
|
||||
atf_add_test_case identical
|
||||
atf_add_test_case multiple_success
|
||||
atf_add_test_case multiple_notfound
|
||||
}
|
Loading…
Reference in New Issue
Block a user