From 9c3427d16f73b98b28adbc2f43f43fe8b865ee6b Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Wed, 28 Apr 2021 10:22:24 +0200 Subject: [PATCH] tests: add tests for abuild-keygen --- tests/abuild-keygen.bats | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/abuild-keygen.bats diff --git a/tests/abuild-keygen.bats b/tests/abuild-keygen.bats new file mode 100644 index 0000000..e90d7f9 --- /dev/null +++ b/tests/abuild-keygen.bats @@ -0,0 +1,31 @@ +setup() { + export ABUILD_KEYGEN="$PWD/../abuild-keygen" + export ABUILD_SHAREDIR="$PWD/.." + tmpdir="$BATS_TMPDIR"/abuild-keygen + export ABUILD_USERDIR="$tmpdir"/user + export PACKAGER="Test User " + mkdir -p "$ABUILD_USERDIR" +} + +teardown() { + rm -rf "$tmpdir" +} + +@test "abuild-keygen: help text" { + $ABUILD_KEYGEN --help +} + +@test "abuild-keygen: generate key non-interactively" { + $ABUILD_KEYGEN -n +} + +@test "abuild-keygen: --append option" { + $ABUILD_KEYGEN --append -n + grep ^PACKAGER_PRIVKEY= "$ABUILD_USERDIR"/abuild.conf +} + +@test "abuild-keygen: --install option fails without SUDO" { + run SUDO=false $ABUILD_KEYGEN --install + [ $status -ne 0 ] +} +