• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sschmid / pw-terminal-password-manager / 15099683798

18 May 2025 08:19PM UTC coverage: 87.677%. Remained the same
15099683798

push

github

sschmid
Stricter config parsing

18 of 18 new or added lines in 1 file covered. (100.0%)

1 existing line in 1 file now uncovered.

434 of 495 relevant lines covered (87.68%)

465.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

98.61
/test/test-helper.bash
1
# shellcheck disable=SC2034
2
_common_setup() {
3
  load 'test_helper/bats-support/load.bash'
900✔
4
  load 'test_helper/bats-assert/load.bash'
900✔
5
  load 'test_helper/bats-file/load.bash'
900✔
6

7
  export XDG_CONFIG_HOME="${BATS_TEST_TMPDIR}/.config"
1,350✔
8
  PW_CONFIG="${XDG_CONFIG_HOME}/pw/pw.conf"
900✔
9
  mkdir -p "${XDG_CONFIG_HOME}/pw"
900✔
10

11
  PROJECT_ROOT="$(cd "${BATS_TEST_DIRNAME}/.." &>/dev/null && pwd)"
2,700✔
12
  PATH="${PROJECT_ROOT}/src:${PATH}"
900✔
13

14
  KEYCHAIN_TEST_PASSWORD=" test password "
900✔
15
  NAME_A=" a test name "
900✔
16
  NAME_B=" b test name "
900✔
17
  ACCOUNT_A=" a test account "
900✔
18
  ACCOUNT_B=" b test account "
900✔
19
  URL_A=" a test url "
900✔
20
  URL_B=" b test url "
900✔
21
  SINGLE_LINE_NOTES=" a single line note "
900✔
22
  MULTI_LINE_NOTES=" a test note
23
with multiple lines
24
and spaces "
900✔
25
  PW_1=" 1 test pw "
900✔
26
  PW_2=" 2 test pw "
900✔
27
  PW_3=" 3 test pw "
900✔
28
}
29

30
_set_config_with_plugin() {
31
  cat > "${PW_CONFIG}" << EOF
560✔
32
[plugins]
33
pluginX = invalid
34
plugin = $1
35
EOF
36
}
37

38
_set_config_with_test_plugins() {
39
  cat > "${1:-"${PW_CONFIG}"}" << EOF
272✔
40
[plugins]
41
pluginX = invalid
42
plugin = ${BATS_TEST_DIRNAME}/fixtures/plugins/collision
43
plugin = ${BATS_TEST_DIRNAME}/fixtures/plugins/test
44
EOF
45
}
46

47
_config_append_keychains() {
48
  echo "[keychains]" >> "${PW_CONFIG}"
56✔
49
  printf "keychain = %s\n" "$@" >> "${PW_CONFIG}"
56✔
50
}
51

52
_config_append_keychains_with_key() {
53
  echo "[keychains]" >> "${PW_CONFIG}"
24✔
54
  printf "%s\n" "$@" >> "${PW_CONFIG}"
24✔
55
}
56

57
assert_init_already_exists() {
58
  run pw init "${PW_KEYCHAIN}"
12✔
59
  assert_failure
12✔
60
  assert_output "pw: ${PW_KEYCHAIN} already exists."
12✔
61
}
62

63
assert_item_exists() {
64
  local password="$1"; shift
632✔
65
  run pw -p "$@"
316✔
66
  assert_success
316✔
67
  assert_output "${password}"
316✔
68
}
69

70
assert_item_not_exists() {
71
  run pw "$@"
56✔
72
  assert_failure
56✔
73
  assert_item_not_exists_output "$@"
56✔
74
}
75

76
assert_adds_item() {
77
  local password="$1"; shift
608✔
78
  run pw add "$@" <<< "${password}"
304✔
79
  assert_success
304✔
80
  refute_output
304✔
81
}
82

83
assert_adds_item_with_keychain_password() {
84
  local password="$1"; shift
272✔
85
  run pw add "$@" << EOF
136✔
86
${KEYCHAIN_TEST_PASSWORD}
87
${password}
88
EOF
89
  assert_success
136✔
90
  refute_output
136✔
91
}
92

93
assert_item_already_exists() {
94
  local password="$1"; shift
24✔
95
  run pw add "$@" <<< "${password}"
12✔
96
  assert_failure
12✔
97
  assert_item_already_exists_output "$@"
12✔
98
}
99

100
assert_item_already_exists_with_keychain_password() {
101
  local password="$1"; shift
8✔
102
  run pw add "$@" << EOF
4✔
103
${KEYCHAIN_TEST_PASSWORD}
104
${password}
105
EOF
106
  assert_failure
4✔
107
  assert_item_already_exists_output "$@"
4✔
108
}
109

110
assert_removes_item() {
111
  run pw rm "$@"
36✔
112
  assert_success
36✔
113
  assert_removes_item_output "$@"
36✔
114
}
115

116
assert_rm_not_found() {
117
  run pw rm "$@"
20✔
118
  assert_failure
20✔
119
  assert_rm_not_found_output "$@"
20✔
120
}
121

122
assert_edits_item() {
123
  local password="$1"; shift
80✔
124
  run pw edit "$@" <<< "${password}"
40✔
125
  assert_success
40✔
126
  refute_output
40✔
127
}
128

129
assert_edits_item_with_keychain_password() {
130
  local password="$1"; shift
48✔
131
  run pw edit "$@" << EOF
24✔
132
${KEYCHAIN_TEST_PASSWORD}
133
${password}
134
EOF
135
  assert_success
24✔
136
  refute_output
24✔
137
}
138

139
_copy() {
140
  "${PROJECT_ROOT}/src/copy"
12✔
141
}
142

143
_paste() {
144
  "${PROJECT_ROOT}/src/paste"
18✔
145
}
146

147
_skip_when_not_macos() {
148
  [[ "${OSTYPE}" == "darwin"* ]] || skip "Not macOS"
4✔
149
}
150

151
_skip_manual_test() {
152
  if [[ -v PW_TEST_RUN_MANUAL_TESTS ]]; then
72✔
UNCOV
153
    echo "# Please enter $1" >&3
×
154
  else
155
    skip "Requires user input. Use PW_TEST_RUN_MANUAL_TESTS=1 test/run to also run manual tests."
72✔
156
  fi
157
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc