#
# Part of the ht://Dig package   <http://www.htdig.org/>
# Copyright (c) 1999-2003 The ht://Dig Group
# For copyright details, see the file COPYING in your distribution
# or the GNU Library General Public License (LGPL) version 2 or later
# <http://www.gnu.org/copyleft/lgpl.html>
#
# $Id: t_htdig_local,v 1.7 2003/09/27 06:53:29 lha Exp $
#

test_functions_action=--start-apache
. ./test_functions

#test for local-file-system access to <http://...> URLs

expected='bad_local.htm'
got=`$htdig "$@" -t -i -vv -c $testdir/conf/htdig.conf2 | grep "Bad local extension:" | sed -e"s-.*/--"`
if [ "$expected" != "$got" ]
then
	fail "running htdig: expected 
$expected
but got
$got"

fi

$htpurge -c $testdir/conf/htdig.conf2

# should  http://localhost:7400/set1/sub%2520dir  be purged?
expected='http://localhost:7400/set1/
http://localhost:7400/set1/bad_local.htm
http://localhost:7400/set1/script.html
http://localhost:7400/set1/site%201.html
http://localhost:7400/set1/site2.html
http://localhost:7400/set1/site3.html
http://localhost:7400/set1/site4.html
http://localhost:7400/set1/sub%2520dir/
http://localhost:7400/set1/sub%2520dir/empty%20file.html
http://localhost:7400/set1/title.html'

got=`./document -c $testdir/conf/htdig.conf2 -u | sort`

if [ "$expected" != "$got" ]
then
	fail "running htdig: expected 
$expected
but got
$got"

fi


#test for  <file:///...> URLs

expected=''	# no "bad local" extensions for file:///
sed "s#^start_url.*#start_url: file://$PWD/htdocs/set1/#" < $testdir/conf/htdig.conf2 > tmp.conf
got=`$htdig "$@" -t -i -vv -c tmp.conf | grep "Bad local extension:" | sed -e"s-.*/--"`
if [ "$expected" != "$got" ]
then
	fail "running htdig: expected 
$expected
but got
$got"

fi

$htpurge -c $testdir/conf/htdig.conf2

expected='file:///set1/bad_local.htm
file:///set1/index.html
file:///set1/script.html
file:///set1/site%201.html
file:///set1/site2.html
file:///set1/site3.html
file:///set1/site4.html
file:///set1/sub%2520dir/empty%20file.html
file:///set1/title.html'

got=`./document -c tmp.conf -u | sed "s#${PWD}/htdocs##" | sort`

if [ "$expected" != "$got" ]
then
	fail "running htdig: expected 
$expected
but got
$got"

fi

test_functions_action=--stop-apache
. ./test_functions
