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

sschmid / pw-terminal-password-manager / 20728970303

05 Jan 2026 08:59PM UTC coverage: 87.429% (-0.1%) from 87.524%
20728970303

push

github

sschmid
Debug PWD

4 of 5 new or added lines in 1 file covered. (80.0%)

459 of 525 relevant lines covered (87.43%)

645.51 hits per line

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

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

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

11
        PROJECT_ROOT="$(cd "${BATS_TEST_DIRNAME}/.." &>/dev/null && pwd)"
2,704✔
12
        PATH="${PROJECT_ROOT}/src:${PATH}"
898✔
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_copy_paste() {
31
        cat > "${PW_CONFIG}" << 'EOF'
564✔
32
[general]
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"
26✔
44
}
45

46
_config_append_with_plugin() {
47
        cat >> "${PW_CONFIG}" << EOF
552✔
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
280✔
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
600✔
83
        run pw -p "$@"
300✔
84
        assert_success
296✔
85
        assert_output "${password}"
296✔
86
}
87

88
assert_item_not_exists() {
89
        run pw "$@"
52✔
90
        assert_failure
32✔
91
        assert_item_not_exists_output "$@"
36✔
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
132✔
108
        refute_output
132✔
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
×
125
        assert_item_already_exists_output "$@"
×
126
}
127

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

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

140
assert_edits_item() {
141
        local password="$1"; shift
80✔
142
        run pw edit "$@" <<< "${password}"
40✔
143
        assert_success
36✔
144
        refute_output
36✔
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"
×
159
}
160

161
_skip_manual_test() {
162
        if [[ -v PW_TEST_RUN_MANUAL_TESTS ]]; then
72✔
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
}
168

169
_skip_if_github_action() {
170
        echo "Debug PWD: ${PWD}"
4✔
171
        if [[ "${PWD}" != *"/runner/work/"* ]]; then
4✔
NEW
172
                echo "NOT SKIPPING"
×
173
        else
174
                echo "SKIPPING"
4✔
175
                skip "$@"
4✔
176
        fi
177
}
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