tests: port abump tests
This commit is contained in:
parent
9d5b268aec
commit
ce6e5964b2
118
tests/abump.bats
118
tests/abump.bats
|
@ -1,118 +0,0 @@
|
||||||
setup() {
|
|
||||||
export ABUILD="$PWD/../abuild"
|
|
||||||
export ABUMP="$PWD/../abump"
|
|
||||||
export ABUILD_KEYGEN="$PWD/../abuild-keygen"
|
|
||||||
export ABUILD_SHAREDIR="$PWD/.."
|
|
||||||
export ABUILD_CONF=/dev/null
|
|
||||||
export ABUILD_USERDIR="$BATS_TEST_TMPDIR"/.config
|
|
||||||
export PACKAGER="Test User <user@example.com>"
|
|
||||||
export REPODEST="$BATS_TEST_TMPDIR"/packages
|
|
||||||
mkdir -p $BATS_TEST_TMPDIR
|
|
||||||
export CLEANUP="srcdir bldroot pkgdir deps"
|
|
||||||
export APORTSDIR="$BATS_TEST_TMPDIR"
|
|
||||||
export ABUILD_OPTS=""
|
|
||||||
export ABUILD_APK_INDEX_OPTS="--keys-dir=$ABUILD_USERDIR"
|
|
||||||
export PATH="$PWD/../:$PATH"
|
|
||||||
|
|
||||||
$ABUILD_KEYGEN --append -n
|
|
||||||
|
|
||||||
cd "$BATS_TEST_TMPDIR"
|
|
||||||
git init --quiet
|
|
||||||
git config user.email "user@example.com"
|
|
||||||
git config user.name "Test User"
|
|
||||||
}
|
|
||||||
|
|
||||||
teardown() {
|
|
||||||
rm -rf "$BATS_TEST_TMPDIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "abump: help text" {
|
|
||||||
$ABUMP -h
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "abump: simple bump" {
|
|
||||||
mkdir -p "$BATS_TEST_TMPDIR"/main/foo
|
|
||||||
cd "$BATS_TEST_TMPDIR"/main/foo
|
|
||||||
echo "first" > foo-1.0.txt
|
|
||||||
echo "second" > foo-1.1.txt
|
|
||||||
cat > APKBUILD <<-EOF
|
|
||||||
# Maintainer: Test user <user@example.com>
|
|
||||||
pkgname="foo"
|
|
||||||
pkgver=1.0
|
|
||||||
pkgrel=0
|
|
||||||
pkgdesc="dummy package for test"
|
|
||||||
url="https://alpinelinux.org"
|
|
||||||
license="MIT"
|
|
||||||
arch="noarch"
|
|
||||||
source="foo-\$pkgver.txt"
|
|
||||||
options="!check"
|
|
||||||
package() {
|
|
||||||
install -D "\$srcdir"/foo-\$pkgver.txt "\$pkgdir"/foo
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$ABUILD checksum
|
|
||||||
$ABUILD
|
|
||||||
git add APKBUILD foo-1.0.txt
|
|
||||||
git commit -m "test commit"
|
|
||||||
|
|
||||||
$ABUMP foo-1.1
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "abump: test bumping same version" {
|
|
||||||
mkdir -p "$BATS_TEST_TMPDIR"/main/foo
|
|
||||||
cd "$BATS_TEST_TMPDIR"/main/foo
|
|
||||||
echo "first" > foo-1.0.txt
|
|
||||||
echo "second" > foo-1.1.txt
|
|
||||||
cat > APKBUILD <<-EOF
|
|
||||||
# Maintainer: Test user <user@example.com>
|
|
||||||
pkgname="foo"
|
|
||||||
pkgver=1.0
|
|
||||||
pkgrel=0
|
|
||||||
pkgdesc="dummy package for test"
|
|
||||||
url="https://alpinelinux.org"
|
|
||||||
license="MIT"
|
|
||||||
arch="noarch"
|
|
||||||
source="foo-\$pkgver.txt"
|
|
||||||
options="!check"
|
|
||||||
package() {
|
|
||||||
install -D "\$srcdir"/foo-\$pkgver.txt "\$pkgdir"/foo
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$ABUILD checksum
|
|
||||||
$ABUILD
|
|
||||||
git add APKBUILD foo-1.0.txt
|
|
||||||
git commit -m "test commit"
|
|
||||||
|
|
||||||
run $ABUMP foo-1.0
|
|
||||||
[ $status -ne 0 ]
|
|
||||||
}
|
|
||||||
|
|
||||||
@test "abump: test bumping same version which is not in git" {
|
|
||||||
mkdir -p "$BATS_TEST_TMPDIR"/main/foo
|
|
||||||
cd "$BATS_TEST_TMPDIR"/main/foo
|
|
||||||
echo "first" > foo-1.0.txt
|
|
||||||
echo "second" > foo-1.1.txt
|
|
||||||
cat > APKBUILD <<-EOF
|
|
||||||
# Maintainer: Test user <user@example.com>
|
|
||||||
pkgname="foo"
|
|
||||||
pkgver=1.0
|
|
||||||
pkgrel=0
|
|
||||||
pkgdesc="dummy package for test"
|
|
||||||
url="https://alpinelinux.org"
|
|
||||||
license="MIT"
|
|
||||||
arch="noarch"
|
|
||||||
source="foo-\$pkgver.txt"
|
|
||||||
options="!check"
|
|
||||||
package() {
|
|
||||||
install -D "\$srcdir"/foo-\$pkgver.txt "\$pkgdir"/foo
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
$ABUILD checksum
|
|
||||||
$ABUILD
|
|
||||||
git add APKBUILD foo-1.0.txt
|
|
||||||
git commit -m "test commit"
|
|
||||||
|
|
||||||
sed -i -e 's/pkgver=.*/pkgver=1.1/' APKBUILD
|
|
||||||
|
|
||||||
$ABUMP foo-1.1
|
|
||||||
}
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
#!/usr/bin/env atf-sh
|
||||||
|
|
||||||
|
. $(atf_get_srcdir)/test_env.sh
|
||||||
|
init_tests \
|
||||||
|
abump_help \
|
||||||
|
abump_invalid_opt \
|
||||||
|
abump_missing_args \
|
||||||
|
abump_simple_bump
|
||||||
|
|
||||||
|
export ABUILD_SHAREDIR=$(atf_get_srcdir)/..
|
||||||
|
export GIT_CONFIG_GLOBAL="$(atf_get_srcdir)/testdata/gitconfig"
|
||||||
|
export APORTSDIR="$PWD"
|
||||||
|
export ABUILD_OPTS=""
|
||||||
|
export ABUILD_APK_INDEX_OPTS="--allow-untrusted"
|
||||||
|
export REPODEST="$PWD"/packages
|
||||||
|
|
||||||
|
abump_help_body() {
|
||||||
|
atf_check -s exit:0 \
|
||||||
|
-o match:"Usage" \
|
||||||
|
abump -h
|
||||||
|
}
|
||||||
|
|
||||||
|
abump_invalid_opt_body() {
|
||||||
|
atf_check -s exit:2 \
|
||||||
|
-e match:"Usage" \
|
||||||
|
abump -@
|
||||||
|
}
|
||||||
|
|
||||||
|
abump_missing_args_body() {
|
||||||
|
atf_check -s exit:2 \
|
||||||
|
-e match:"Usage" \
|
||||||
|
abump
|
||||||
|
}
|
||||||
|
|
||||||
|
abump_simple_bump_body() {
|
||||||
|
cp -r "$(atf_get_srcdir)"/testdata/.abuild .
|
||||||
|
git init
|
||||||
|
mkdir -p main/foo
|
||||||
|
cd main/foo
|
||||||
|
echo "first" > foo-1.0.txt
|
||||||
|
cat > APKBUILD <<-EOF
|
||||||
|
# Maintainer: Test user <user@example.com>
|
||||||
|
pkgname="foo"
|
||||||
|
pkgver=1.0
|
||||||
|
pkgrel=0
|
||||||
|
pkgdesc="dummy package for test"
|
||||||
|
url="https://alpinelinux.org"
|
||||||
|
license="MIT"
|
||||||
|
arch="noarch"
|
||||||
|
source="foo-\$pkgver.txt"
|
||||||
|
options="!check"
|
||||||
|
package() {
|
||||||
|
install -D "\$srcdir"/foo-\$pkgver.txt "\$pkgdir"/foo
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
abuild checksum
|
||||||
|
abuild
|
||||||
|
git add APKBUILD foo-1.0.txt
|
||||||
|
git commit -m "test commit"
|
||||||
|
|
||||||
|
echo "second" > foo-1.1.txt
|
||||||
|
atf_check \
|
||||||
|
-o match:"foo-1.1.txt: OK" \
|
||||||
|
-e match:"upgrade to 1.1" \
|
||||||
|
abump foo-1.1
|
||||||
|
|
||||||
|
atf_check -s exit:1 \
|
||||||
|
-e match:">>> ERROR: version is already 1.1" \
|
||||||
|
abump foo-1.1
|
||||||
|
|
||||||
|
sed -i -e 's/pkgver=.*/pkgver=1.2/' APKBUILD
|
||||||
|
echo "third" > foo-1.2.txt
|
||||||
|
atf_check \
|
||||||
|
-o match:"foo-1.2.txt: OK" \
|
||||||
|
-e match:"upgrade to 1.2" \
|
||||||
|
abump foo-1.2
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[color]
|
||||||
|
ui = always
|
||||||
|
[user]
|
||||||
|
name = Joe User
|
||||||
|
email = juser@example.com
|
Loading…
Reference in New Issue