load ../lib/common @test "libreblacklist works with just pkgname" { v="$(libreblacklist normalize <<> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST='phony://example.com' eot libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ $status != 0 ]] empty $tmpdir/stdout not empty $tmpdir/stderr } @test "libreblacklist fails cat with no blacklist or network" { cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST='phony://example.com' eot libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ $status != 0 ]] empty $tmpdir/stdout not empty $tmpdir/stderr } @test "libreblacklist fails update when BLACKLIST is unset" { cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST= eot libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ $status != 0 ]] empty $tmpdir/stdout not empty $tmpdir/stderr } @test "libreblacklist fails cat when syntax error in conf" { # there is a stray single quote in there cat >> "$XDG_CONFIG_HOME/libretools/libretools.conf" <<-eot BLACKLIST='https://git.parabola.nu/blacklist.git/plain/blacklist.txt eot libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ $status != 0 ]] empty $tmpdir/stdout not empty $tmpdir/stderr } @test "libreblacklist downloads the blacklist as needed" { require network || skip libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr not empty $tmpdir/stdout } @test "libreblacklist downloads the blacklist repeatedly" { require network || skip libreblacklist update libreblacklist update } @test "libreblacklist displays help and fails with no args" { LC_ALL=C libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || status=$? [[ $status != 0 ]] empty $tmpdir/stdout [[ "$(sed 1q $tmpdir/stderr)" =~ 'Usage: libreblacklist ' ]] } @test "libreblacklist displays help when given h" { LC_ALL=C libreblacklist -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ 'Usage: libreblacklist ' ]] empty $tmpdir/stderr } @test "libreblacklist displays help when given h cat" { LC_ALL=C libreblacklist -h cat >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" == 'Usage: libreblacklist cat' ]] empty $tmpdir/stderr }