summaryrefslogtreecommitdiff
path: root/test/lib-blacklist-test.sh
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-09-30 00:27:23 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-10-01 17:35:22 -0400
commit4014f6c2cc579645aac56f51aa6063db7815c3a8 (patch)
tree549afea90ba2a0283c1507cd276a28d3e4fb243a /test/lib-blacklist-test.sh
parent61e61226d8aeb2a973656a263cd0c523e9e55c88 (diff)
test: Clean up (config) file writing
Instead of using in inconsistent mish-mash of `mkdir` and `echo >` and `printf >>`, use more readable and identifiable indented-heredocs: install -Dm644 /dev/stdin "FILENAME" <<-eot CONTENTS eot
Diffstat (limited to 'test/lib-blacklist-test.sh')
-rwxr-xr-xtest/lib-blacklist-test.sh30
1 files changed, 18 insertions, 12 deletions
diff --git a/test/lib-blacklist-test.sh b/test/lib-blacklist-test.sh
index 742f1c2..920e99d 100755
--- a/test/lib-blacklist-test.sh
+++ b/test/lib-blacklist-test.sh
@@ -51,8 +51,9 @@ it_prints_urls_only_for_valid_references() {
}
it_fails_update_with_no_blacklist_or_network() {
- mkdir -p $XDG_CONFIG_HOME/libretools
- echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST='phony://example.com'
+ eot
libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
@@ -62,8 +63,9 @@ it_fails_update_with_no_blacklist_or_network() {
}
it_fails_cat_with_no_blacklist_or_network() {
- mkdir -p $XDG_CONFIG_HOME/libretools
- echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST='phony://example.com'
+ eot
libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
@@ -73,8 +75,9 @@ it_fails_cat_with_no_blacklist_or_network() {
}
it_fails_update_when_BLACKLIST_is_unset() {
- mkdir -p $XDG_CONFIG_HOME/libretools
- echo "BLACKLIST=" >$XDG_CONFIG_HOME/libretools/libretools.conf
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST=
+ eot
libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
@@ -84,9 +87,10 @@ it_fails_update_when_BLACKLIST_is_unset() {
}
it_fails_cat_when_syntax_error_in_conf() {
- mkdir -p $XDG_CONFIG_HOME/libretools
# there is a stray single quote in there
- printf "BLACKLIST='%q\n" "${_blacklist_url}" >$XDG_CONFIG_HOME/libretools/libretools.conf
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST='${_blacklist_url@Q}
+ eot
libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$?
@@ -97,8 +101,9 @@ it_fails_cat_when_syntax_error_in_conf() {
it_downloads_the_blacklist_as_needed() {
require network || return 0
- mkdir -p $XDG_CONFIG_HOME/libretools
- printf 'BLACKLIST=%q\n' "${_blacklist_url}" >$XDG_CONFIG_HOME/libretools/libretools.conf
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST=${_blacklist_url@Q}
+ eot
libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr
@@ -107,8 +112,9 @@ it_downloads_the_blacklist_as_needed() {
it_downloads_the_blacklist_repeatedly() {
require network || return 0
- mkdir -p $XDG_CONFIG_HOME/libretools
- printf 'BLACKLIST=%q\n' "${_blacklist_url}" >$XDG_CONFIG_HOME/libretools/libretools.conf
+ install -Dm644 /dev/stdin "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot
+ BLACKLIST=${_blacklist_url@Q}
+ eot
libreblacklist update
libreblacklist update