From f977850ea950fedab922349ab25e9565d01c1453 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 26 May 2014 11:34:53 +0100 Subject: [PATCH] Add tests for __expand_path layout helper --- test/lib/layout-helpers/__expand_path-test.sh | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 test/lib/layout-helpers/__expand_path-test.sh diff --git a/test/lib/layout-helpers/__expand_path-test.sh b/test/lib/layout-helpers/__expand_path-test.sh new file mode 100755 index 0000000..f94069f --- /dev/null +++ b/test/lib/layout-helpers/__expand_path-test.sh @@ -0,0 +1,27 @@ +#! /usr/bin/env bash +source "../../test-helper.sh" +source "${root}/lib/layout-helpers.sh" + +# +# __expand_path() tests. +# + +# Setup. +realHOME="$HOME" +HOME="/home/test-user" + +# When given a path containing "~", it expands "~" to "$HOME". +assert '__expand_path "~/Foo/Bar"' "${HOME}/Foo/Bar" + +# When given a path without "~", it returns path as is. +assert '__expand_path "/path/to/file"' "/path/to/file" + +# When given a path containing spaces, it returns path correctly. +assert '__expand_path "~/Path To/File"' "${HOME}/Path To/File" + +# Tear down. +HOME="$realHOME" +unset realHOME + +# End of tests. +assert_end "__expand_path()"