#!/bin/sh

set -e

test_dir="$AUTOPKGTEST_TMP"
if [ -z "$test_dir" ] ; then
    test_dir="$(mktemp -d)"
fi

name=hs-2009-25-n-web

solve-field debian/tests/${name}.jpg -D ${test_dir} 2>&1 |\
    tee ${test_dir}/${name}.log

for ext in axy solved match wcs rdls corr new ; do
    ls -l ${test_dir}/${name}.${ext}
    test -s ${test_dir}/${name}.${ext}
done

echo Check if the Carina constellation was found here
grep -q Carina ${test_dir}/${name}.log

# Check some stars which are close to the edges
for s in 'ρ Cen' 'μ Vel' 'β Cha' 'η Mus' 'Alsephina (δ Vel)' 'μ2 Cru'; do
    echo Check that $s was found
    grep -q "The star $s" ${test_dir}/${name}.log
done

if [ "$test_dir" != "$AUTOPKGTEST_TMP" ] ; then
   rm -rf "$test_dir"
fi
