commit 808245bc6bd9298d9dde2987e6bb7e94230504d0
parent 43d20962461e09de50a620493edb2c730b675b60
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Fri, 25 Oct 2024 17:56:34 +0000
Delete command is fully covered by integrated suites
Diffstat:
2 files changed, 60 insertions(+), 7 deletions(-)
diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh
@@ -137,11 +137,12 @@ Describe 'Integrated Command Functions'
BeforeEach setup
AfterEach cleanup
- cat() { @cat "$@"; }
- diff() { @diff "$@"; }
- git() { @git "$@"; }
- mktemp() { @mktemp "$@"; }
- rm() { @rm "$@"; }
+ cat() { @cat "$@"; }
+ diff() { @diff "$@"; }
+ dirname() { @dirname "$@"; }
+ git() { @git "$@"; }
+ mktemp() { @mktemp "$@"; }
+ rm() { @rm "$@"; }
platform_tmpdir() {
SECURE_TMPDIR="${SHELLSPEC_WORKDIR}/secure"
@@ -150,7 +151,36 @@ Describe 'Integrated Command Functions'
# Describe 'cmd_copy' is not needed (covered by 'cmd_copy_move')
# Describe 'cmd_copy_move'
-# Describe 'cmd_delete'
+
+ Describe 'cmd_delete'
+ DECISION=default
+
+ It 'deletes multiple files at once, prompting before each one'
+ Data
+ #|y
+ #|n
+ #|y
+ End
+ When call cmd_delete stale subdir/file fluff/two
+ The output should equal 'Are you sure you would like to delete stale? [y/n]Are you sure you would like to delete subdir/file? [y/n]Are you sure you would like to delete fluff/two? [y/n]'
+ The error should be blank
+ The file "${PREFIX}/fluff/two.age" should not be exist
+ The file "${PREFIX}/stale.age" should not be exist
+ The file "${PREFIX}/subdir/file.age" should be exist
+ expected_log() { %text
+ #|Remove fluff/two from store.
+ #|
+ #| fluff/two.age | 4 ----
+ #| 1 file changed, 4 deletions(-)
+ #|Remove stale from store.
+ #|
+ #| stale.age | 3 ---
+ #| 1 file changed, 3 deletions(-)
+ setup_log
+ }
+ The result of function check_git_log should be successful
+ End
+ End
Describe 'cmd_edit'
It 'uses EDITOR in a dumb terminal'
diff --git a/spec/pass_spec.sh b/spec/pass_spec.sh
@@ -1512,7 +1512,7 @@ Describe 'Pass-like command'
It 'removes a directory when forced and recursive'
Skip if 'pass(age) needs bash' check_skip $2
- When run script $1 rm -rf fluff/
+ When run script $1 rm -rf fluff
The directory "${PREFIX}/fluff" should not be exist
expected_log() { %text:expand
#|Remove fluff/ from store.
@@ -1552,6 +1552,18 @@ Describe 'Pass-like command'
The contents of file "${GITLOG}" should equal "$(expected_log $3)"
End
+ It 'does not remove anything with `/` suffix but no recursive flag'
+ Skip if 'pass(age) needs bash' check_skip $2
+ When run script $1 rm -f extra/
+ The error should include 'extra/'
+ The error should include 's a directory'
+ The directory "${PREFIX}/extra" should be exist
+ The file "${PREFIX}/extra.age" should be exist
+ The file "${PREFIX}/extra.gpg" should be exist
+ The result of function git_log should be successful
+ The contents of file "${GITLOG}" should equal "$(setup_log)"
+ End
+
It 'fails to remove a non-existent directory'
Skip if 'pass(age) needs bash' check_skip $2
When run script $1 rm -rf stale/
@@ -1572,6 +1584,17 @@ Describe 'Pass-like command'
The contents of file "${GITLOG}" should equal "$(setup_log)"
End
+ It 'does not remove an unencrypted file with `/` suffix'
+ Skip if 'pass(age) needs bash' check_skip $2
+ When run script $1 rm -rf y.txt/
+ The status should equal 1
+ The output should be blank
+ The error should include 'y.txt'
+ The file "${PREFIX}/y.txt" should be exist
+ The result of function git_log should be successful
+ The contents of file "${GITLOG}" should equal "$(setup_log)"
+ End
+
It 'rejects a path containing ..'
Skip if 'pass(age) needs bash' check_skip $2
When run script $1 delete subdir/../fluff/one