[aur-dev] [PATCH 4/3] Add tests for the restore command

Lukas Fleischer lfleischer at archlinux.org
Sat Aug 6 08:48:55 UTC 2016


Test the restore mode of git-serve and git-update.

Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
Another bunch of tests that will land on pu.

 git-interface/test/t0002-serve.sh  | 17 +++++++++++++++++
 git-interface/test/t0003-update.sh | 29 +++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/git-interface/test/t0002-serve.sh b/git-interface/test/t0002-serve.sh
index f36f1d8..52fdcd1 100755
--- a/git-interface/test/t0002-serve.sh
+++ b/git-interface/test/t0002-serve.sh
@@ -85,4 +85,21 @@ test_expect_success "Try to push to someone else's repository as Trusted User."
 	test_cmp expected actual
 '
 
+test_expect_success "Test restore." '
+	echo "DELETE FROM PackageBases WHERE Name = \"foobar\";" | \
+	sqlite3 aur.db &&
+	cat >expected <<-EOF &&
+	user
+	foobar
+	EOF
+	SSH_ORIGINAL_COMMAND="restore foobar" AUR_USER=user AUR_PRIVILEGED=0 \
+	"$GIT_SERVE" 2>&1 >actual
+	test_cmp expected actual
+'
+
+test_expect_success "Try to restore an existing package base." '
+	SSH_ORIGINAL_COMMAND="restore foobar2" AUR_USER=user AUR_PRIVILEGED=0 \
+	test_must_fail "$GIT_SERVE" 2>&1
+'
+
 test_done
diff --git a/git-interface/test/t0003-update.sh b/git-interface/test/t0003-update.sh
index 810b860..81c5687 100755
--- a/git-interface/test/t0003-update.sh
+++ b/git-interface/test/t0003-update.sh
@@ -85,6 +85,35 @@ test_expect_success 'Test update hook on an updated repository.' '
 	test_cmp expected actual
 '
 
+test_expect_success 'Test restore mode.' '
+	AUR_USER=user AUR_PKGBASE=foobar AUR_PRIVILEGED=0 \
+	"$GIT_UPDATE" restore 2>&1 &&
+	cat >expected <<-EOF &&
+	2|2|foobar2|1-1|aurweb test package.|https://aur.archlinux.org/
+	3|1|foobar|1-2|aurweb test package.|https://aur.archlinux.org/
+	1|GPL
+	2|MIT
+	2|2
+	3|1
+	2|1|python-pygit2||
+	3|1|python-pygit2||
+	1|1
+	2|1
+	EOF
+	>actual &&
+	for t in Packages Licenses PackageLicenses Groups PackageGroups \
+		PackageDepends PackageRelations PackageSources \
+		PackageNotifications; do
+		echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual
+	done &&
+	test_cmp expected actual
+'
+
+test_expect_success 'Test restore mode on a non-existent repository.' '
+	AUR_USER=user AUR_PKGBASE=foobar3 AUR_PRIVILEGED=0 \
+	test_must_fail "$GIT_UPDATE" restore 2>&1
+'
+
 test_expect_success 'Pushing to a branch other than master.' '
 	old=0000000000000000000000000000000000000000 &&
 	new=$(git -C aur.git rev-parse HEAD) &&
-- 
2.9.2


More information about the aur-dev mailing list