[PATCH 2/2] tests: Added tests for the list command.

Holger Dell zx2c4.com at holgerdell.com
Sun May 24 16:29:57 CEST 2020


- List credentials.
- Do not list hidden credentials.

Signed-off-by: Holger Dell <holgerdell at users.noreply.github.com>
---
 tests/t0030-list-tests.sh | 42 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100755 tests/t0030-list-tests.sh

diff --git a/tests/t0030-list-tests.sh b/tests/t0030-list-tests.sh
new file mode 100755
index 0000000..458265e
--- /dev/null
+++ b/tests/t0030-list-tests.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+test_description='Test list'
+cd "$(dirname "$0")"
+. ./setup.sh
+
+test_expect_success 'Test "list" command' '
+	"$PASS" init $KEY1 &&
+	"$PASS" generate cred1 20 &&
+	"$PASS" generate cred2 20 &&
+	"$PASS" list | grep -qe "cred1" &&
+	"$PASS" list | grep -qe "cred2"
+	"$PASS" | grep -qe "cred1"
+	"$PASS" | grep -qe "cred2"
+'
+
+test_expect_success 'Test "list" command with subdirectory' '
+	"$PASS" generate dir1/cred3 20 &&
+	"$PASS" list dir1 | grep -qve "cred1" &&
+	"$PASS" list dir1 | grep -qve "cred2" &&
+	"$PASS" list dir1 | grep -qe "cred3"
+	"$PASS" list | grep -qe "cred1" &&
+	"$PASS" list | grep -qe "cred2" &&
+	"$PASS" list | grep -qe "cred3"
+'
+
+test_expect_success 'Test "list" command with hidden password file' '
+	"$PASS" generate dir2/.cred4 20 &&
+	"$PASS" list dir2 | grep -qve "cred4" &&
+	"$PASS" list dir1 | grep -qve "cred4" &&
+	"$PASS" list | grep -qve "cred4" &&
+	"$PASS" list dir2/.cred4
+'
+
+test_expect_success 'Test "list" command with hidden directory' '
+	"$PASS" generate .dir3/cred5 20 &&
+	"$PASS" list | grep -qve "cred5" &&
+	"$PASS" list .dir3 | grep -qe "cred5" &&
+	"$PASS" list .dir3/cred5
+'
+
+test_done
-- 
2.25.1



More information about the Password-Store mailing list