small pixel drawing of a pufferfish pa

add fail func
Jes Olson j3s@c3f.net
Tue, 01 Oct 2024 15:35:27 -0400
commit

06b996a4d8deb35e90e44afa9b322e5180f2d021

parent

63cc5197395f52f2054ec35f950d7c21ce540aa4

1 files changed, 21 insertions(+), 11 deletions(-)

jump to
M testtest

@@ -2,6 +2,12 @@ #!/bin/sh

# # test - a pa test script +failures=0 +fail() { + printf "%s\n" "$*" + failures=$((failures + 1)) +} + export PA_DIR=test-stuff/passwords # clean up previous run

@@ -13,42 +19,46 @@ rm -rf test-stuff

# pa welcomes you ./pa | grep -q "a simple password manager" || - printf "pa should print a welcome message\n" + fail "pa should print a welcome message" # generate pa dirs/identityfile/recipientfile ./pa list # pa auto-generated files are correct test -s test-stuff/identities || - printf "an identities file should exist\n" + fail "an identities file should exist" test -s test-stuff/recipients || - printf "a recipients file should exist\n" + fail "a recipients file should exist" test -d "$PA_DIR/.git" || - printf "git dir should exist\n" + fail "git dir should exist" # TODO: ensure git author/email are set correctly, etc # pa add printf 'y' | ./pa add test 2>&1 >/dev/null || - printf "pa add should be capable of adding a test password\n" + fail "pa add should be capable of adding a test password" -test "$(printf y | $pa add nested/password 2>&1)" = "\ +test "$(printf y | ./pa add nested/password 2>&1)" = "\ Generate a password? [y/N]: y Saved 'nested/password' to the store." || - printf 'pa add should say it stored nested/password\n' + fail "pa add should say it stored nested/password" test -s test-stuff/passwords/nested/password.age || - printf 'pa add should create an encrypted password file\n' + fail "pa add should create an encrypted password file" # pa list ./pa list | grep -q test || - printf "pa list should list the test password\n" + fail "pa list should list the test password" test "$(./pa list)" = "nested/password test" || - printf 'pa list output should match example\n' + fail "pa list output should match example" # ensure git commits are working git -C test-stuff/passwords log | grep -q "add 'nested/password'" || - printf "git log should have line: add 'nested/password'\n" + fail "git log should have line: add 'nested/password'" + +# print info & exit w/ correct status +printf "\ntotal failures: %d\n" "$failures" +test "$failures" -eq 0