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

sschmid / pw-terminal-password-manager / 15236460862

25 May 2025 09:27AM UTC coverage: 87.475% (-0.2%) from 87.677%
15236460862

push

github

sschmid
Export variables

22 of 23 new or added lines in 5 files covered. (95.65%)

40 existing lines in 4 files now uncovered.

440 of 503 relevant lines covered (87.48%)

567.46 hits per line

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

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

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

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

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

30
_set_config_with_copy_paste() {
31
  cat > "${PW_CONFIG}" << 'EOF'
568✔
32
[config]
33
copy = cat > "${BATS_TEST_TMPDIR}/test_clipboard"
34
paste = cat "${BATS_TEST_TMPDIR}/test_clipboard"
35
EOF
36
}
37

38
_copy() {
39
  cat > "${BATS_TEST_TMPDIR}/test_clipboard"
12✔
40
}
41

42
_paste() {
43
  cat "${BATS_TEST_TMPDIR}/test_clipboard"
18✔
44
}
45

46
_config_append_with_plugin() {
47
  cat >> "${PW_CONFIG}" << EOF
560✔
48
[plugins]
49
# unknown key
50
pluginX = invalid
51
plugin = $1
52
EOF
53
}
54

55
_config_append_with_test_plugins() {
56
  cat >> "${1:-"${PW_CONFIG}"}" << EOF
276✔
57
[plugins]
58
# unknown key
59
pluginX = invalid
60
plugin = ${BATS_TEST_DIRNAME}/fixtures/plugins/collision
61
plugin = ${BATS_TEST_DIRNAME}/fixtures/plugins/test
62
EOF
63
}
64

65
_config_append_keychains() {
66
  echo "[keychains]" >> "${PW_CONFIG}"
56✔
67
  printf "keychain = %s\n" "$@" >> "${PW_CONFIG}"
56✔
68
}
69

70
_config_append_keychains_with_key() {
71
  echo "[keychains]" >> "${PW_CONFIG}"
24✔
72
  printf "%s\n" "$@" >> "${PW_CONFIG}"
24✔
73
}
74

75
assert_init_already_exists() {
76
  run pw init "${PW_KEYCHAIN}"
12✔
77
  assert_failure
12✔
78
  assert_output "pw: ${PW_KEYCHAIN} already exists."
12✔
79
}
80

81
assert_item_exists() {
82
  local password="$1"; shift
632✔
83
  run pw -p "$@"
316✔
84
  assert_success
316✔
85
  assert_output "${password}"
316✔
86
}
87

88
assert_item_not_exists() {
89
  run pw "$@"
56✔
90
  assert_failure
56✔
91
  assert_item_not_exists_output "$@"
56✔
92
}
93

94
assert_adds_item() {
95
  local password="$1"; shift
608✔
96
  run pw add "$@" <<< "${password}"
304✔
97
  assert_success
304✔
98
  refute_output
304✔
99
}
100

101
assert_adds_item_with_keychain_password() {
102
  local password="$1"; shift
272✔
103
  run pw add "$@" << EOF
136✔
104
${KEYCHAIN_TEST_PASSWORD}
105
${password}
106
EOF
107
  assert_success
136✔
108
  refute_output
136✔
109
}
110

111
assert_item_already_exists() {
112
  local password="$1"; shift
24✔
113
  run pw add "$@" <<< "${password}"
12✔
114
  assert_failure
12✔
115
  assert_item_already_exists_output "$@"
12✔
116
}
117

118
assert_item_already_exists_with_keychain_password() {
119
  local password="$1"; shift
8✔
120
  run pw add "$@" << EOF
4✔
121
${KEYCHAIN_TEST_PASSWORD}
122
${password}
123
EOF
124
  assert_failure
4✔
125
  assert_item_already_exists_output "$@"
4✔
126
}
127

128
assert_removes_item() {
129
  run pw rm "$@"
36✔
130
  assert_success
36✔
131
  assert_removes_item_output "$@"
36✔
132
}
133

134
assert_rm_not_found() {
135
  run pw rm "$@"
20✔
136
  assert_failure
20✔
137
  assert_rm_not_found_output "$@"
20✔
138
}
139

140
assert_edits_item() {
141
  local password="$1"; shift
80✔
142
  run pw edit "$@" <<< "${password}"
40✔
143
  assert_success
40✔
144
  refute_output
40✔
145
}
146

147
assert_edits_item_with_keychain_password() {
148
  local password="$1"; shift
48✔
149
  run pw edit "$@" << EOF
24✔
150
${KEYCHAIN_TEST_PASSWORD}
151
${password}
152
EOF
153
  assert_success
24✔
154
  refute_output
24✔
155
}
156

157
_skip_when_not_macos() {
158
  [[ "${OSTYPE}" == "darwin"* ]] || skip "Not macOS"
4✔
159
}
160

161
_skip_manual_test() {
162
  if [[ -v PW_TEST_RUN_MANUAL_TESTS ]]; then
72✔
UNCOV
163
    echo "# Please enter $1" >&3
×
164
  else
165
    skip "Requires user input. Use test/run -m to also run manual tests."
72✔
166
  fi
167
}
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