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

sschmid / pw-terminal-password-manager / 20733526656

06 Jan 2026 12:25AM UTC coverage: 87.123% (+0.03%) from 87.097%
20733526656

push

github

sschmid
gpg: Add ignore_path do ignore false positives

433 of 497 relevant lines covered (87.12%)

415.24 hits per line

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

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

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

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

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

30
_set_config_with_copy_paste() {
31
        cat > "${PW_CONFIG}" << 'EOF'
584✔
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
572✔
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
568✔
83
        run pw -p "$@"
284✔
84
        assert_success
284✔
85
        assert_output "${password}"
284✔
86
}
87

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

94
assert_adds_item() {
95
        local password="$1"; shift
592✔
96
        run pw add "$@" <<< "${password}"
296✔
97
        assert_success
292✔
98
        refute_output
292✔
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
124✔
108
        refute_output
124✔
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
40✔
144
        refute_output
40✔
145
}
146

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

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