#!/bin/sh

set -e

. ./helpers.sh

# When the top changelog entry is UNRELEASED and its version was already
# uploaded to unstable, the aUNRELEASED dance must make dch -i bump the
# version, and the new entry must stay UNRELEASED.

set_stub_rmadison "openstack-pkg-tools | 1.0.0-1 | unstable | source, all" 0
make_fixture "1.0.0-1" UNRELEASED "openstack-pkg-tools" \
	"UPSTREAM_GIT := https://github.com/openstack/openstack-pkg-tools.git"

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

assert_eq "version bumped" "$(dpkg-parsechangelog -SVersion)" "1.0.0-2"
assert_eq "distribution kept UNRELEASED" "$(dpkg-parsechangelog -SDistribution)" "UNRELEASED"
assert_contains "old entry untouched" "$(cat debian/changelog)" "openstack-pkg-tools (1.0.0-1) UNRELEASED"

exit 0
