From c59808ecc1956a653f8df7110d281fa9027cdd64 Mon Sep 17 00:00:00 2001 From: Michael Wolf Date: Sat, 30 Sep 2023 12:20:58 -0600 Subject: [PATCH] Add first cut at some tests --- tests/project-root1.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 tests/project-root1.sh diff --git a/tests/project-root1.sh b/tests/project-root1.sh new file mode 100755 index 0000000..e0a4efe --- /dev/null +++ b/tests/project-root1.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +cd "$DIR"/.. || exit + +source ./_reformat-common.bash + +setUp() { + cd "$DIR"/.. || exit +} + +testProjectRoot001() { + dir=$(mktemp -d --tmpdir would-reformat-testProjectRoot001.XXXXXX) + cd "$dir" || exit + git init >/dev/null 2>&1 + + echo 'abc123' >random-file + + pr=$(project_root random-file) + + assertEquals "$dir" "$pr" +} + +# This won't work (yet) because our only method of determining a +# project root is to ask git what it thinks. +testProjectRoot002() { + dir=$(mktemp -d --tmpdir would-reformat-testProjectRoot001.XXXXXX) + cd "$dir" || exit + + echo 'abc123' >random-file + + pr=$(project_root random-file) + + assertEquals "" "$pr" +} + +# shellcheck disable=SC1091 +source shunit2