#!/usr/bin/env roundup describe libreblacklist . ./test-common.sh before() { _before } after() { _after } it_works_with_just_pkgname() { v="$(libreblacklist normalize <<$XDG_CONFIG_HOME/libretools/libretools.conf libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] [[ -z "$(cat $tmpdir/stdout)" ]] [[ -n "$(cat $tmpdir/stderr)" ]] } it_fails_cat_when_there_is_no_blacklist_or_network() { mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST='phony://example.com'" >$XDG_CONFIG_HOME/libretools/libretools.conf libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] [[ -z "$(cat $tmpdir/stdout)" ]] [[ -n "$(cat $tmpdir/stderr)" ]] } it_fails_update_when_BLACKLIST_is_unset() { mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST=" >$XDG_CONFIG_HOME/libretools/libretools.conf libreblacklist update >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] [[ -z "$(cat $tmpdir/stdout)" ]] [[ -n "$(cat $tmpdir/stderr)" ]] } it_fails_cat_when_syntax_error_in_conf() { mkdir -p $XDG_CONFIG_HOME/libretools # there is a stray single quote in there echo "BLACKLIST='https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] [[ -z "$(cat $tmpdir/stdout)" ]] [[ -n "$(cat $tmpdir/stderr)" ]] } it_downloads_the_blacklist_as_needed() { require network || return 0 mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf libreblacklist cat >$tmpdir/stdout 2>$tmpdir/stderr [[ -n "$(cat $tmpdir/stdout)" ]] } it_downloads_the_blacklist_repeatedly() { require network || return 0 mkdir -p $XDG_CONFIG_HOME/libretools echo "BLACKLIST=https://repo.parabolagnulinux.org/docs/blacklist.txt" >$XDG_CONFIG_HOME/libretools/libretools.conf libreblacklist update libreblacklist update } it_displays_help_and_fails_with_no_args() { libreblacklist >$tmpdir/stdout 2>$tmpdir/stderr || stat=$? [[ $stat != 0 ]] [[ -z "$(cat $tmpdir/stdout)" ]] [[ "$(sed 1q $tmpdir/stderr)" =~ 'Usage: libreblacklist ' ]] } it_displays_help_when_given_h() { libreblacklist -h >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ 'Usage: libreblacklist ' ]] [[ -z "$(cat $tmpdir/stderr)" ]] } it_displays_help_when_given_h_cat() { libreblacklist -h cat >$tmpdir/stdout 2>$tmpdir/stderr [[ "$(sed 1q $tmpdir/stdout)" =~ 'Usage: libreblacklist cat' ]] [[ -z "$(cat $tmpdir/stderr)" ]] } # TODO: test blacklist-update, but I don't want tests to use network