#!/bin/bash
set -eu

TESTDIR=$(readlink -f $(dirname $0))
. $TESTDIR/framework-without-repo

setupenvironment

buildpackage 'simple-package'
buildpackage 'conflicting-package-one'

aptgetinstallpackage 'simple-package'
aptgetinstallpackage 'conflicting-package-one'

testpkginstalled 'simple-package'
testpkginstalled 'conflicting-package-one'

if [ -n "$APT_TEST_GPGPUBKEY" ]; then
	state_with_gpgpubkey='
gpg-pubkey manual'
	manual_with_gpgpubkey='
gpg-pubkey'
else
	state_with_gpgpubkey=''
	manual_with_gpgpubkey=''
fi
readonly state_with_gpgpubkey manual_with_gpgpubkey

testequal 'Reading Package Lists...
Building Dependency Tree...
conflicting-package-one manual
simple-package manual' aptmark showstate simple-package conflicting-package-one

testequal "Reading Package Lists...
Building Dependency Tree...
conflicting-package-one manual${state_with_gpgpubkey}
simple-package manual" aptmark showstate

testequal 'Reading Package Lists...
Building Dependency Tree...' aptmark showauto

testequal "Reading Package Lists...
Building Dependency Tree...
conflicting-package-one${manual_with_gpgpubkey}
simple-package" aptmark showmanual

testsuccess aptmark auto simple-package

testequal 'Reading Package Lists...
Building Dependency Tree...
conflicting-package-one manual
simple-package auto' aptmark showstate simple-package conflicting-package-one

testequal 'Reading Package Lists...
Building Dependency Tree...
conflicting-package-one manual' aptmark showstate conflicting-package-one

testequal "Reading Package Lists...
Building Dependency Tree...
conflicting-package-one manual${state_with_gpgpubkey}
simple-package auto" aptmark showstate

testequal 'Reading Package Lists...
Building Dependency Tree...
simple-package' aptmark showauto

testequal "Reading Package Lists...
Building Dependency Tree...
conflicting-package-one${manual_with_gpgpubkey}" aptmark showmanual
