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

sschmid / pw-terminal-password-manager / 15057524665

16 May 2025 12:00AM UTC coverage: 87.778% (+0.02%) from 87.76%
15057524665

push

github

sschmid
Update Dockerfiles

395 of 450 relevant lines covered (87.78%)

449.14 hits per line

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

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

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

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

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

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

37
_set_config_with_test_plugins() {
38
  cat > "${1:-"${PW_CONFIG}"}" << EOF
260✔
39
[plugins]
40
${BATS_TEST_DIRNAME}/fixtures/plugins/collision
41
${BATS_TEST_DIRNAME}/fixtures/plugins/test
42
EOF
43
}
44

45
_config_append_keychains() {
46
  echo "[keychains]" >> "${PW_CONFIG}"
80✔
47
  printf "%s\n" "$@" >> "${PW_CONFIG}"
80✔
48
}
49

50
assert_init_already_exists() {
51
  run pw init "${PW_KEYCHAIN}"
12✔
52
  assert_failure
12✔
53
  assert_output "pw: ${PW_KEYCHAIN} already exists."
12✔
54
}
55

56
assert_item_exists() {
57
  local password="$1"; shift
632✔
58
  run pw -p "$@"
316✔
59
  assert_success
316✔
60
  assert_output "${password}"
316✔
61
}
62

63
assert_item_not_exists() {
64
  run pw "$@"
56✔
65
  assert_failure
56✔
66
  assert_item_not_exists_output "$@"
56✔
67
}
68

69
assert_adds_item() {
70
  local password="$1"; shift
608✔
71
  run pw add "$@" <<< "${password}"
304✔
72
  assert_success
304✔
73
  refute_output
304✔
74
}
75

76
assert_adds_item_with_keychain_password() {
77
  local password="$1"; shift
272✔
78
  run pw add "$@" << EOF
136✔
79
${KEYCHAIN_TEST_PASSWORD}
80
${password}
81
EOF
82
  assert_success
136✔
83
  refute_output
136✔
84
}
85

86
assert_item_already_exists() {
87
  local password="$1"; shift
24✔
88
  run pw add "$@" <<< "${password}"
12✔
89
  assert_failure
12✔
90
  assert_item_already_exists_output "$@"
12✔
91
}
92

93
assert_item_already_exists_with_keychain_password() {
94
  local password="$1"; shift
8✔
95
  run pw add "$@" << EOF
4✔
96
${KEYCHAIN_TEST_PASSWORD}
97
${password}
98
EOF
99
  assert_failure
4✔
100
  assert_item_already_exists_output "$@"
4✔
101
}
102

103
assert_removes_item() {
104
  run pw rm "$@"
36✔
105
  assert_success
36✔
106
  assert_removes_item_output "$@"
36✔
107
}
108

109
assert_rm_not_found() {
110
  run pw rm "$@"
20✔
111
  assert_failure
20✔
112
  assert_rm_not_found_output "$@"
20✔
113
}
114

115
assert_edits_item() {
116
  local password="$1"; shift
80✔
117
  run pw edit "$@" <<< "${password}"
40✔
118
  assert_success
40✔
119
  refute_output
40✔
120
}
121

122
assert_edits_item_with_keychain_password() {
123
  local password="$1"; shift
48✔
124
  run pw edit "$@" << EOF
24✔
125
${KEYCHAIN_TEST_PASSWORD}
126
${password}
127
EOF
128
  assert_success
24✔
129
  refute_output
24✔
130
}
131

132
_copy() {
133
  "${PROJECT_ROOT}/src/copy"
12✔
134
}
135

136
_paste() {
137
  "${PROJECT_ROOT}/src/paste"
18✔
138
}
139

140
_skip_when_not_macos() {
141
  [[ "${OSTYPE}" == "darwin"* ]] || skip "Not macOS"
4✔
142
}
143

144
_skip_manual_test() {
145
  if [[ -v PW_TEST_RUN_MANUAL_TESTS ]]; then
72✔
146
    echo "# Please enter $1" >&3
×
147
  else
148
    skip "Requires user input. Use PW_TEST_RUN_MANUAL_TESTS=1 test/run to also run manual tests."
72✔
149
  fi
150
}
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