##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.70-maint/%M%
#   Revision:		%I%
#   First Edition:	2017/11/27
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:        is-saved
#   Modulefiles:
#   Sub-Command:
#
#   Comment:	%C{
#           Test 'is-saved' module command
#		}C%
#
##############################################################################

# set HOME to location containing collections
set homewithcoll "$env(HOME)/home"
if { $verbose > 0 } {
    send_user "\tSetup HOME = $homewithcoll\n"
}
set env(HOME) "$homewithcoll"


#
#  The tests
#

testouterr_cmd "ALL" "is-saved foo" "ERR" ""
testouterr_cmd "ALL" "is-saved foo coll1" "OK" ""
testouterr_cmd "sh" "is-saved" "OK" ""

# define a collection target
if { $verbose > 0 } {
    send_user "\tSetup MODULES_COLLECTION_TARGET = 'target'\n"
}
set env(MODULES_COLLECTION_TARGET) "target"

testouterr_cmd "sh" "is-saved foo coll1" "ERR" ""
testouterr_cmd "sh" "is-saved coll4" "OK" ""
testouterr_cmd "sh" "is-saved" "OK" ""

# define a collection target with no collection related to it
if { $verbose > 0 } {
    send_user "\tSetup MODULES_COLLECTION_TARGET = 'foo'\n"
}
set env(MODULES_COLLECTION_TARGET) "foo"

testouterr_cmd "sh" "is-saved" "ERR" ""

# test unsetting HOME
if { $verbose > 0 } {
    send_user "\tUnset HOME \n"
}
unset env(HOME)

testouterr_cmd "sh" "is-saved" "ERR" "$error_msgs: HOME not defined"


#
#  Cleanup
#

reset_test_env
