commit 7b7f7d3f0c9deb34513dd90a08ecfeb2d2245d56
parent 3e29cc6b6bb06b827980f290d7bb36b44c747440
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sat, 2 Nov 2024 08:48:07 +0000
Init command is fully covered by integrated suites
Diffstat:
2 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/spec/pashage_extra_spec.sh b/spec/pashage_extra_spec.sh
@@ -145,6 +145,7 @@ Describe 'Integrated Command Functions'
git() { @git "$@"; }
mkdir() { @mkdir "$@"; }
mktemp() { @mktemp "$@"; }
+ mv() { @mv "$@"; }
rm() { @rm "$@"; }
tr() { @tr "$@"; }
@@ -546,7 +547,34 @@ Describe 'Integrated Command Functions'
End
End
-# Describe 'cmd_init'
+ Describe 'cmd_init'
+ DECISION=default
+
+ It 're-encrypts the whole store using a recipient ids named like a flag'
+ When run cmd_init -- -p 'new-id'
+ The status should be success
+ The output should equal 'Password store recipients set at store root'
+ The error should be blank
+ expected_file() { %text
+ #|-p
+ #|new-id
+ }
+ The contents of file "${PREFIX}/.age-recipients" should \
+ equal "$(expected_file)"
+ expected_log() { %text
+ #|Set age recipients at store root
+ #|
+ #| .age-recipients | 2 ++
+ #| extra/subdir/file.age | 3 ++-
+ #| stale.age | 4 ++--
+ #| subdir/file.age | 3 ++-
+ #| 4 files changed, 8 insertions(+), 4 deletions(-)
+ setup_log
+ }
+ The result of function check_git_log should be successful
+ End
+ End
+
# Describe 'cmd_insert'
# Describe 'cmd_list_or_show'
# Describe 'cmd_move' is not needed (covered by 'cmd_copy_move')
diff --git a/spec/pass_spec.sh b/spec/pass_spec.sh
@@ -384,7 +384,7 @@ Describe 'Pass-like command'
It 're-encrypts a subdirectory after replacing recipient ids'
Skip if 'pass(age) needs bash' check_skip $2
Skip if 'passage has no init' [ "$2" = passage ]
- When run script $1 init -p fluff 'new-id' 'new-master'
+ When run script $1 init --path=fluff 'new-id' 'new-master'
The status should be success
The output should start with 'Password store'
The output should include 'fluff'
@@ -420,7 +420,7 @@ Describe 'Pass-like command'
It 're-encrypts a subdirectory after removing dedicated recipient ids'
Skip if 'pass(age) needs bash' check_skip $2
Skip if 'passage has no init' [ "$2" = passage ]
- When run script $1 init -p fluff ''
+ When run script $1 init -pfluff ''
The status should be successful
expected_log() {
if [ "$2" = pashage ]; then
@@ -502,6 +502,30 @@ Describe 'Pass-like command'
The contents of file "${GITLOG}" should equal "$(setup_log)"
End
+ It 'displays usage when called with incomplete flag'
+ Skip if 'pass(age) needs bash' check_skip $2
+ Skip if 'passage has no init' [ "$2" = passage ]
+ When run script $1 init -p
+ The status should equal 1
+ The output should be blank
+ The error should include 'Usage:'
+ The error should include ' init '
+ The result of function git_log should be successful
+ The contents of file "${GITLOG}" should equal "$(setup_log)"
+ End
+
+ It 'displays usage when called with unknown flag'
+ Skip if 'pass(age) needs bash' check_skip $2
+ Skip if 'passage has no init' [ "$2" = passage ]
+ When run script $1 init -x new-id-1 new-id-2
+ The status should equal 1
+ The output should be blank
+ The error should include 'Usage:'
+ The error should include ' init '
+ 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
Skip if 'passage has no init' [ "$2" = passage ]