#!/bin/bash

TD="$(dirname "$0")"
. "$TD/testlib.sh"
if [ -n "$PBUILDER_CHECKOUT" ]; then
    PBUILDER_SATISFYDEPENDS_CHECKPARAMS="$PBUILDER_CHECKOUT/pbuilder-satisfydepends-checkparams"
else
    PBUILDER_SATISFYDEPENDS_CHECKPARAMS="$PBUILDER_TEST_PKGLIBDIR/pbuilder-satisfydepends-checkparams"
fi

# testsuite to test pbuilder-satisfydepends-checkparams.

# mock function
checkbuilddep_internal() {
    : # do nothing function    
}

test_chrootexec2() {
    set -- --internal-chrootexec 'chroot /tmp-hoge ' --chroot /tmp
    . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
}
expect_fail test_chrootexec2

test_chrootexec1() {
    set -- --chroot /tmp --internal-chrootexec 'chroot /tmp-hoge '
    . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
}
expect_success test_chrootexec1

test_chrootexec_echo() {
    set -- --echo --chroot /tmp
    . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
}
expect_fail test_chrootexec_echo

test_chrootexec_echo2() {
    set -- --chroot /tmp --echo 
    . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
    echo $CHROOTEXEC
}
expect_output "echo chroot /tmp" test_chrootexec_echo2 

test_chrootexec_expect() {
    set -- --chroot /tmp --internal-chrootexec 'chroot /tmp-hoge '
    . "$PBUILDER_SATISFYDEPENDS_CHECKPARAMS"
    echo $CHROOTEXEC
}
expect_output "chroot /tmp-hoge" test_chrootexec_expect 

testlib_summary
