|
| 1 | +#! /usr/bin/env atf-sh |
| 2 | +# Test that xbps-fetch works as expected. |
| 3 | + |
| 4 | +atf_test_case success |
| 5 | + |
| 6 | +success_head() { |
| 7 | + atf_set "descr" "xbps-fetch: test successful remote fetch" |
| 8 | +} |
| 9 | + |
| 10 | +success_body() { |
| 11 | + mkdir some_repo |
| 12 | + touch some_repo/pkg_A |
| 13 | + xbps-fetch file://$PWD/some_repo/pkg_A |
| 14 | + atf_check_equal $? 0 |
| 15 | +} |
| 16 | + |
| 17 | +atf_test_case pkgnotfound |
| 18 | + |
| 19 | +pkgnotfound_head() { |
| 20 | + atf_set "descr" "xbps-fetch: test remote package not found" |
| 21 | +} |
| 22 | + |
| 23 | +pkgnotfound_body() { |
| 24 | + xbps-fetch file://$PWD/nonexistant |
| 25 | + atf_check_equal $? 1 |
| 26 | +} |
| 27 | + |
| 28 | +atf_test_case identical |
| 29 | + |
| 30 | +identical_head() { |
| 31 | + atf_set "descr" "xbps-fetch: test fetching identical file from remote" |
| 32 | +} |
| 33 | + |
| 34 | +identical_body() { |
| 35 | + mkdir some_repo |
| 36 | + echo 'content' > some_repo/pkg_A |
| 37 | + echo 'content' > pkg_A |
| 38 | + output=$(xbps-fetch file://$PWD/some_repo/pkg_A 2>&1) |
| 39 | + atf_check_equal $? 0 |
| 40 | + atf_check_equal "$output" "file://$PWD/some_repo/pkg_A: file is identical with remote." |
| 41 | +} |
| 42 | + |
| 43 | +atf_test_case multiple_success |
| 44 | + |
| 45 | +multiple_success_head() { |
| 46 | + atf_set "descr" "xbps-fetch: test fetching multiple remote files" |
| 47 | +} |
| 48 | + |
| 49 | +multiple_success_body() { |
| 50 | + mkdir some_repo |
| 51 | + touch some_repo/pkg_A some_repo/pkg_B |
| 52 | + xbps-fetch file://$PWD/some_repo/pkg_A file://$PWD/some_repo/pkg_B |
| 53 | + atf_check_equal $? 0 |
| 54 | + test -f pkg_A |
| 55 | + atf_check_equal $? 0 |
| 56 | + test -f pkg_B |
| 57 | + atf_check_equal $? 0 |
| 58 | +} |
| 59 | + |
| 60 | +atf_test_case multiple_notfound |
| 61 | + |
| 62 | +multiple_notfound_head() { |
| 63 | + atf_set "descr" "xbps-fetch: test fetching multiple remote files, with one not found" |
| 64 | +} |
| 65 | + |
| 66 | +multiple_notfound_body() { |
| 67 | + mkdir some_repo |
| 68 | + touch some_repo/pkg_A |
| 69 | + xbps-fetch file://$PWD/some_repo/nonexistant file://$PWD/some_repo/pkg_A |
| 70 | + atf_check_equal $? 1 |
| 71 | + test -f pkg_A |
| 72 | + atf_check_equal $? 0 |
| 73 | + test -f nonexistant |
| 74 | + atf_check_equal $? 1 |
| 75 | +} |
| 76 | + |
| 77 | +atf_init_test_cases() { |
| 78 | + atf_add_test_case success |
| 79 | + atf_add_test_case pkgnotfound |
| 80 | + atf_add_test_case identical |
| 81 | + atf_add_test_case multiple_success |
| 82 | + atf_add_test_case multiple_notfound |
| 83 | +} |
0 commit comments