-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test cases for xbps-fetch, including testing for: - remote file identical with local file - multiple files fetched - error handling for multiple files fetched
- Loading branch information
Showing
5 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
syntax("kyuafile", 1) | ||
|
||
test_suite("xbps-fetch") | ||
atf_test_program{name="fetch_test"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
TOPDIR = ../../.. | ||
-include $(TOPDIR)/config.mk | ||
|
||
TESTSHELL = fetch_test | ||
TESTSSUBDIR = xbps/xbps-fetch | ||
EXTRA_FILES = Kyuafile | ||
|
||
include $(TOPDIR)/mk/test.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |