#!/bin/sh

set -eu

export PUAVO_CONF_DB_FILEPATH=test_puavo-conf.db
rm -f "${PUAVO_CONF_DB_FILEPATH}"

empty_list=$(../puavo-conf)
[ -z "${empty_list}" ] || {
    echo 'TestError: empty_list is not empty' >&2
    exit 1
}

../puavo-conf var1 value1 2>/dev/null && {
    echo "TestError: overwriting a parameter with an empty db did not fail" >&2
    exit 1
}

../puavo-conf --set-mode=add var1 value1

../puavo-conf --help >/dev/null || {
    echo "TestError: --help exited with status $? status" >&2
    exit 1
}

../puavo-conf --set-mode=add var2 true

../puavo-conf var2 false

echo "puavo-conf is OK"

true
