mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2025-02-04 13:42:03 +00:00
tests: add tests for abuild-fetch
This commit is contained in:
parent
4e548b722b
commit
d708a813a3
36
tests/abuild-fetch.bats
Normal file
36
tests/abuild-fetch.bats
Normal file
@ -0,0 +1,36 @@
|
||||
setup() {
|
||||
export ABUILD_FETCH="$PWD/../abuild-fetch"
|
||||
|
||||
tmpdir="$BATS_TMPDIR"/abuild-fetch
|
||||
bindir="$tmpdir"/bin
|
||||
mkdir -p "$bindir"
|
||||
export PATH="$bindir:$PATH"
|
||||
|
||||
# fake curl
|
||||
cat >> "$bindir"/curl <<-EOF
|
||||
#!/bin/sh
|
||||
|
||||
touch "$tmpdir"/curl-invoked
|
||||
echo "Fake curl invoked with: \$@"
|
||||
exit \${CURL_EXITCODE:-0}
|
||||
EOF
|
||||
chmod +x "$bindir"/curl
|
||||
}
|
||||
|
||||
teardown() {
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
@test "abuild-fetch: help text" {
|
||||
$ABUILD_FETCH -h
|
||||
}
|
||||
|
||||
@test "abuild-fetch: test curl invocation" {
|
||||
$ABUILD_FETCH -d "$tmpdir" https://example.com/non-existing
|
||||
[ -f "$tmpdir"/curl-invoked ]
|
||||
}
|
||||
|
||||
@test "abuild-fetch: test curl failure" {
|
||||
run CURL_EXITCODE=1 $ABUILD_FETCH -d "$tmpdir" https://example.com/non-existing
|
||||
[ $status -ne 0 ]
|
||||
}
|
Loading…
Reference in New Issue
Block a user