aboutsummaryrefslogtreecommitdiff
path: root/t/tests.sh
diff options
context:
space:
mode:
authorMiquel Sabaté <mikisabate@gmail.com>2015-08-01 23:45:55 +0200
committerMiquel Sabaté <mikisabate@gmail.com>2015-08-01 23:45:55 +0200
commit112819777c7f77a47a97474dee21bbe1cfe531ec (patch)
treeef19201173696b0d7e4e2aad518b22dab8d1e35a /t/tests.sh
parent0c254aded5a945a2bba1ab30265c344392a7f4fa (diff)
downloadg-112819777c7f77a47a97474dee21bbe1cfe531ec.tar.gz
g-112819777c7f77a47a97474dee21bbe1cfe531ec.zip
The test suite is working just fine
Diffstat (limited to 't/tests.sh')
-rw-r--r--t/tests.sh66
1 files changed, 64 insertions, 2 deletions
diff --git a/t/tests.sh b/t/tests.sh
index 79c635f..a0d32e2 100644
--- a/t/tests.sh
+++ b/t/tests.sh
@@ -15,5 +15,67 @@
set -e
-echo "Hello World"
-exit 0
+# Cleanup previous tests and setup some special variables.
+d="$(realpath $(dirname $0))"
+rm -f $d/output.txt
+HOME="$d"
+
+# Setup the test file system.
+mkdir -p $d/a/b/c
+mkdir -p $d/a/d
+
+source $d/../g.sh
+
+# First check that the basic commands are there.
+g -v &>> $d/output.txt
+g --version &>> $d/output.txt
+g -h &>> $d/output.txt
+g --help &>> $d/output.txt
+
+# Let's add some shortcuts.
+cd $d
+g add root
+g add b a/b
+g add c a/b/c
+
+# Errors on the `add` command.
+set +e
+g add add &>> $d/output.txt
+g add lala lala lala &>> $d/output.txt
+set -e
+
+# Removing shortcuts.
+g rm c
+g rm d
+
+# Errors on the `rm` command.
+set +e
+g rm &>> $d/output.txt
+g rm lala lala &>> $d/output.txt
+set -e
+
+# The list command.
+g list --keys &>> $d/output.txt
+g list | awk '{ print $1 }' | xargs &>> $d/output.txt
+
+# Bare g command.
+original=`pwd`
+cd /
+g b
+basename $(pwd) &>> $d/output.txt
+g root
+basename $(pwd) &>> $d/output.txt
+g root/a/b/c
+basename $(pwd) &>> $d/output.txt
+cd $original
+
+# Unknown shortcut.
+set +e
+g unknown &>> $d/output.txt
+set -e
+
+# Teardown
+diff $d/output.txt $d/expected.txt
+rm $d/output.txt
+rm -rf a
+rm -rf $d/.gfile