#!/bin/bash
set -eu

TESTDIR=$(readlink -f $(dirname $0))

# The hardcoded data below is wrong if there is an extra pkg in the db.
if [ -n "$APT_TEST_GPGPUBKEY" ]; then
	echo 'SKIP (not ready for the presence of APT_TEST_GPGPUBKEY)' >&2
	exit 0
fi

. $TESTDIR/framework

setupenvironment

buildpackage 'conflicting-package-distupgrade'
buildpackage 'conflicting-package-one'
buildpackage 'conflicting-package-two'
buildpackage 'missing-dependency'
buildpackage 'simple-package-new'
buildpackage 'simple-package-noarch'
buildpackage 'simple-package'
buildpackage 'simple-package-update'

generaterepository_and_switch_sources "$TMPWORKINGDIRECTORY/usr/src/RPM/RPMS"

testsuccess aptget update

testregexmatch 'Total Package Names : 7 \([^\)]*\)
  Normal Packages: 0
  Pure Virtual Packages: 0
  Single Virtual Packages: 0
  Mixed Virtual Packages: 6
  Missing: 1
Total Distinct Versions: 8 \([^\)]*\)
Total Dependencies: 7 \([^\)]*\)
Total Ver/File relations: 8 \([^\)]*\)
Total Provides Mappings: 9 \([^\)]*\)
Total Globbed Strings: [0-9]* \([^\)]*\)
Total Dependency Version space: 14
Total Slack space: .*
Total Space Accounted for: .*' \
	       aptcache stats
