summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/aur-test.sh29
-rw-r--r--test/is_built-test.sh60
2 files changed, 89 insertions, 0 deletions
diff --git a/test/aur-test.sh b/test/aur-test.sh
new file mode 100644
index 0000000..1cbcc57
--- /dev/null
+++ b/test/aur-test.sh
@@ -0,0 +1,29 @@
+#!/usr/bin/env roundup
+
+describe aur
+
+before() {
+ tmpdir=$(mktemp -d --tmpdir test-aur.XXXXXXXXXXXX)
+ stat=0
+}
+
+after() {
+ rm -rf -- "$tmpdir"
+}
+
+it_displays_help() {
+ aur -h >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
+}
+
+it_fails_with_0_args() {
+ aur >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+# TODO: I don't have any other tests we can run without networking.
diff --git a/test/is_built-test.sh b/test/is_built-test.sh
new file mode 100644
index 0000000..bcd46f5
--- /dev/null
+++ b/test/is_built-test.sh
@@ -0,0 +1,60 @@
+#!/usr/bin/env roundup
+
+describe is_built
+
+before() {
+ tmpdir=$(mktemp -d --tmpdir test-is_build.XXXXXXXXXXXX)
+ stat=0
+}
+
+after() {
+ rm -rf -- "$tmpdir"
+}
+
+it_displays_help() {
+ is_built -h >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
+}
+
+it_fails_with_0_args() {
+ is_built >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat > 1 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_fails_with_1_arg() {
+ is_built sh >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat > 1 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -n "$(cat $tmpdir/stderr)" ]]
+}
+
+it_returns_1_for_non_existent_package() {
+ is_built phony-ne-package 100 >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat == 1 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
+}
+
+it_returns_1_for_future_packages() {
+ # If emacs ever goes rapid release, we might need to change this :P
+ is_built emacs 100 >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat == 1 ]]
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
+}
+
+it_returns_0_for_past_packages() {
+ # If emacs ever goes rapid release, we might need to change this :P
+ is_built emacs 1 >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ -z "$(cat $tmpdir/stdout)" ]]
+ [[ -z "$(cat $tmpdir/stderr)" ]]
+}