# Each test must have a filename of the pattern
#
#   ${whatever}.test.sh
#
# It is expected to be a GNU Bash script and will be sourced from the
# main script, so it does not need to be executable, nor have a shebang.
#
# Each test must define the two functions test_setup() and
# test_set_assumptions().
#
# The following is an example test case from the sgopherd project.

test_setup()
{
    # Define $request, which will be the exact string sent to sgopherd
    # via stdin. It will later be used by global_run_program().
    request=$'/foo/bar\r\n'

    # You can work in $docroot to create files that you want to be
    # visible to sgopherd. $docroot is created by
    # global_presetup_per_test().
    mkdir "$docroot"/foo
    echo hello >"$docroot"/foo/bar

    # If you want to test corner cases, you can overwrite $servername
    # and $serverport here. They will default to "localhost" and "70"
    # are set by global_presetup_per_test(), too.
    #
    # If you set $remote_host or $remote_addr, they will later be
    # exported to $REMOTE_HOST or $REMOTE_ADDR. This is done by
    # global_run_program().
}

test_set_assumptions()
{
    # You must create these three files (even if they are empty):
    #
    #   $work/stdout.expected
    #   $work/stderr.expected
    #   $work/exitcode.expected
    #
    # (This is not specific to the sgopherd environment. Usage of these
    # files is required by the test framework.)
    #
    # If you need to, you can create additional files in $work. They
    # will be cleaned up afterwards.
    #
    # The stdout/stderr files must contain the exact output which is
    # expected to be sent by sgopherd.

    echo hello >"$work"/stdout.expected
    touch "$work"/stderr.expected
    echo 0 >"$work"/exitcode.expected
}
