expand nothing
cp nothing nothing.orig

expand redirects
expand redirects.golden-auto
expand redirects.golden-all
cp redirects redirects.orig

expand broken
expand broken.golden
cp broken broken.orig

exec xurls -fix nothing
! stdout .
! stderr .
cmp nothing nothing.orig

stdin redirects
exec xurls -fix
cmp stdout redirects.golden-auto
cmp redirects redirects.orig
! stderr .

exec xurls -fix redirects
stdout '^redirects$'
! stderr .
cmp redirects redirects.golden-auto
cp redirects.orig redirects

exec xurls -fix=auto redirects
cmp redirects redirects.golden-auto
cp redirects.orig redirects

exec xurls -fix=all redirects
cmp redirects redirects.golden-all
cp redirects.orig redirects

! exec xurls -fix broken
stdout -count=1 '^broken$'
stderr -count=1 '5 broken urls'
stderr -count=2 '/404 - 404 Not Found'
stderr -count=2 '/500 - 500 Internal Server Error'
stderr -count=1 'totallydoesnotexist.localhost/ - Head .* dial tcp'
cmp broken broken.golden

-- nothing --
No redirect: ${SERVER}/plain-head
-- redirects --
No redirect: ${SERVER}/plain-head
One redirect: ${SERVER}/redir-1
Two redirects: ${SERVER}/redir-2
Redirect inherits fragment: ${SERVER}/redir-1#foo
Redirect replaces fragment: ${SERVER}/redir-fragment#foo

Three links in one line: ${SERVER}/redir-1 + ${SERVER}//redir-1 + ${SERVER}///redir-1

Redirect to a longer path ${SERVER}/redir-longer with trailing text

Permanent redirect codes:
* ${SERVER}/redir-301
* ${SERVER}/redir-308

Temporary redirect codes:
* ${SERVER}/redir-302
* ${SERVER}/redir-303
* ${SERVER}/redir-307

Only GET allowed, HEAD fails: ${SERVER}/get-only
-- redirects.golden-auto --
No redirect: ${SERVER}/plain-head
One redirect: ${SERVER}/plain-head
Two redirects: ${SERVER}/plain-head
Redirect inherits fragment: ${SERVER}/plain-head#foo
Redirect replaces fragment: ${SERVER}/plain-head#bar

Three links in one line: ${SERVER}/plain-head + ${SERVER}/plain-head + ${SERVER}/plain-head

Redirect to a longer path ${SERVER}/redir-longtarget with trailing text

Permanent redirect codes:
* ${SERVER}/plain-head
* ${SERVER}/plain-head

Temporary redirect codes:
* ${SERVER}/redir-302
* ${SERVER}/redir-303
* ${SERVER}/redir-307

Only GET allowed, HEAD fails: ${SERVER}/plain-get
-- redirects.golden-all --
No redirect: ${SERVER}/plain-head
One redirect: ${SERVER}/plain-head
Two redirects: ${SERVER}/plain-head
Redirect inherits fragment: ${SERVER}/plain-head#foo
Redirect replaces fragment: ${SERVER}/plain-head#bar

Three links in one line: ${SERVER}/plain-head + ${SERVER}/plain-head + ${SERVER}/plain-head

Redirect to a longer path ${SERVER}/redir-longtarget with trailing text

Permanent redirect codes:
* ${SERVER}/plain-head
* ${SERVER}/plain-head

Temporary redirect codes:
* ${SERVER}/plain-head
* ${SERVER}/plain-head
* ${SERVER}/plain-head

Only GET allowed, HEAD fails: ${SERVER}/plain-get
-- broken --
One redirect: ${SERVER}/redir-1
404 errors: ${SERVER}/404 ${SERVER}/404
500 errors: ${SERVER}/500 ${SERVER}/500
Dial error: http://totallydoesnotexist.localhost/
-- broken.golden --
One redirect: ${SERVER}/plain-head
404 errors: ${SERVER}/404 ${SERVER}/404
500 errors: ${SERVER}/500 ${SERVER}/500
Dial error: http://totallydoesnotexist.localhost/
