#!/bin/sh

set -e

. ./helpers.sh

# The DEBHELPER_COMPAT and STANDARDS_VERSION values from the pkgos.conf
# file (here: the PKGOS_CONF fixture) drive the debhelper-compat and
# Standards-Version operations, including the text of the git commits
# and of the debian/changelog bullets.

set_stub_rmadison "" 0
printf 'DEBHELPER_COMPAT=14\nSTANDARDS_VERSION=4.8.0\n' > "${TESTCONF}"
make_fixture "1.0.0-1" unstable "openstack-pkg-tools" \
	"UPSTREAM_GIT := https://github.com/openstack/openstack-pkg-tools.git"

run_modernize
assert_eq "exit code" "${MODERNIZE_RC}" "0"

assert_contains "compat from config" "$(cat debian/control)" "debhelper-compat (= 14)"
assert_contains "SV from config" "$(cat debian/control)" "Standards-Version: 4.8.0"
assert_contains "commit title compat" "$(git log --format=%s)" \
	"Upgrade the package to debhelper-compat (= 14)"
assert_contains "commit title SV" "$(git log --format=%s)" \
	"Update Standards-Version to 4.8.0"
assert_contains "bullet compat" "$(cat debian/changelog)" \
	"* Upgrade the package to debhelper-compat (= 14)"
assert_contains "bullet SV" "$(cat debian/changelog)" \
	"* Update Standards-Version to 4.8.0"

exit 0
