#!/bin/sh
#
#   Copyright (C) 1997, 1998
#   	Free Software Foundation, Inc.
#
#   This program is free software; you can redistribute it and/or modify it
#   under the terms of the GNU General Public License as published by the
#   Free Software Foundation; either version 2, or (at your option) any
#   later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
#

. $srcdir/test_functions

if [ "$mifluz" != "yes" ]
then
    # added an error message
    # by benoit orihuela (benoit.orihuela@idealx.com), on 2000/08/02
    echo "index_test needs mifluz library"
    exit 77
fi

samples_base=http://localhost:7400/
samples=http://localhost:7400/index

Iinsert() {
init_sql
#
# Only one URL is crawled and it contains only a few words
#
$crawler -base $testdb -robot_delay 0 -- $samples/simple.html
htdb_dump -W -z -p -s dict inverted 2>&1 | sed -n 's/.*\(fleur\).*/\1/p'
}

Irebuild() {
init_sql
$crawler -base $testdb -robot_delay 0 -- $samples/simple.html
htdb_dump -W -z -p -s index inverted > /tmp/1$$
$crawler -base $testdb -rebuild
htdb_dump -W -z -p -s index inverted > /tmp/2$$
diff /tmp/[12]$$
rm -f /tmp/[12]$$
}

# test the where_url command-line argument
# permits to specifiy a set of urls to rebuild
# added by benoit orihuela (benoit.orihuela@IDEALX.com), on 2000/08/01
Irebuild_where() {
init_sql
$crawler -base $testdb -robot_delay 0 -- $samples_base/langrec.html 
$crawler -base $testdb -robot_delay 0 -- $samples_base/big.html
$crawler -base $testdb -robot_delay 0 -verbose 2 -babil_crawl -rebuild -where_url "url regexp 'big'" 
}

Iiso8859() {
init_sql
$crawler -base $testdb -robot_delay 0 -- $samples/iso8859-1.html
htdb_dump -W -z -p -s dict inverted 2>&1 | sed -n 's/.*\(seance\).*/\1/p'
}


testing ${*:-"Iinsert Iiso8859 Irebuild_where"}




