#!/bin/bash
set -eu

TESTDIR=$(readlink -f $(dirname $0))
. $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

# aptget() below do no accesses to the repo.
#
# apt-get changelog in ALT has nothing
# to do with downloading (unlike in Debian);
# FIXME: it should be apt-cache changelog in ALT.

testregexmatch "Reading Package Lists...
Building Dependency Tree...
Changelog for simple-package:
\* Tue Oct 01 2019 Nobody <nobody@altlinux\.org> 2-alt1
- Test package updated
\* Mon Sep 30 2019 Nobody <somebody@altlinux\.org> 1-alt1
- Test package created

" \
	       aptget changelog 'simple-package'

testregexmatch "Reading Package Lists...
Building Dependency Tree...
Changelog for missing-dependency:
\* Mon Sep 30 2019 Nobody <nobody@altlinux\.org> 1-alt1
- Test package created

" \
	       aptget changelog 'missing-dependency'

# FIXME: the output of the progress of building the caches makes it not empty!
#testempty aptget changelog 'no-such-package'
