#!/bin/bash
# Test case for rasdaman tiff formatter

RADM="--user alan --passwd alan" #set to rasdaman credentials

rasql -q "drop collection tifftest" $RADM
rasql -q "create collection tifftest GreySet3" $RADM
rasql -q "insert into tifftest values marray m in [0:100,0:100,10:10] values 125c" $RADM
rasql -q "update tifftest as x set x assign marray m in [0:100,100:200,10:10] values 250c" $RADM
rasql -q "select tiff(m[*:*,*:*,10:10]) from tifftest as m" --out file --outfile tifftest.tif $RADM

FILE=$(ls | grep tifftest.tif)
echo "$FILE"
if [ "$FILE" == "tifftest.tif.unknown" ] ; then
	echo "WARN: file extension issue still present"
elif [ "$FILE" == "tifftest.tif" ] ; then 
	echo "File name ok"
else
	echo File not found, test failed
	exit 1
fi

TYPE=$(file $FILE | grep TIFF)
echo $TYPE
if [ "$TYPE" != "" ] ; then 
	echo Test passed
	exit 0
else
	echo test failed
	exit 1
fi


