summaryrefslogtreecommitdiff
path: root/test.sh
diff options
context:
space:
mode:
authorSteph Enders <smenders@gmail.com>2023-02-26 22:06:40 -0500
committerSteph Enders <smenders@gmail.com>2023-02-26 22:06:40 -0500
commit9c137d4a179b38f7187e296ae3b0303f5e479c60 (patch)
treee06f5db7e99863d3a56c324b384f0819c34449af /test.sh
parent0791c354995775becf558f4b0031daf55477f88f (diff)
Support splitting files with --- / added tests
Added some tests to verify that you can now split your files with --- to join multiple queries into a single file. This could be for if you have two separate regexes to run or even two sources you want to run the same query against. Example file: ```example.conf query=.*example.conf$ source=/path/to/example/ target=/path/to/dest/ --- query=.*different.csv$ soruce=/path/to/different/ target=/path/to/dest/ ```
Diffstat (limited to 'test.sh')
-rwxr-xr-xtest.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..5d5f48e
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -e
+function prep {
+ mkdir -p test/src
+
+ touch ./test/src/a.txt
+ touch ./test/src/b.txt
+ touch ./test/src/c.txt
+ touch ./test/src/d.txt
+ touch ./test/src/e.txt
+ touch ./test/src/f.txt
+
+ export TARGET_CNT=$(ls -1 ./test/src/ | wc -l)
+
+ mkdir -p ./test/dest
+ rm -f ./test/dest/*.txt
+}
+
+function verify {
+ CNT=$(ls -1 ./test/dest/ | wc -l)
+ if [[ ${CNT} -ne ${TARGET_CNT} ]]; then
+ echo "Test failed: expected ${TARGET_CNT} actual: ${CNT}"
+ exit 1
+ fi
+}
+
+function run {
+ export AUTOMV_DIR=$PWD/test/confs
+ ./automv.sh
+}
+
+prep
+run
+verify
+
+echo "Tests succeeded"