#!/bin/bash
set -e
. tests/lib

t-restrict x-dgit-skip-suite,bullseye
t-restrict x-dgit-skip-suite,buster
t-dependencies T2U

t-t2u-settings
t-debpolicy

t-t2u-native-prep

t-t2u-setup-repo

t-t2u-test
t-t2u-succeeded
t-pushed-good master

# The git tagger has address <dgit-test@debian.example.net>;
# check that Senatus was CCed as the key's owner.
t-t2u-email-expect-headers <<END
    Subject: [tag2upload fake-job] uploaded example 1.0-1
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary=???
    Content-Transfer-Encoding: 8bit
    X-Debian-Tag2upload-Distro: test-dummy
    X-Debian-Tag2upload-JobId: fake-job
    X-Debian-Tag2upload-Url: ???
    X-Debian-Tag2upload-Status: uploaded
    X-Debian-Tag2upload-Package: example
    To: dgit test git user <dgit-test@debian.example.net>
    CC: copies@example.org,
        spqr@example.com
    Reply-To: reply-to@example.org,
        dgit test git user <dgit-test@debian.example.net>
END

# Prepare for another upload.
rm -rf $tmp/t2u
t-archive-process-incoming sid 1.0-1

v=1.0-2
t-dch-commit -v $v -m bump
t-dch-commit-r

# Make Senatus the tagger for this second upload.
git config --local user.name "Senatus Romanus"
git config --local user.email "spqr@example.com"

t-refs-same-start
t-ref-head
t-t2u-test

# This time Senatus should be in To and *not* in CC.
t-t2u-email-expect-headers <<END
    Subject: [tag2upload fake-job] uploaded example 1.0-2
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary=???
    Content-Transfer-Encoding: 8bit
    X-Debian-Tag2upload-Distro: test-dummy
    X-Debian-Tag2upload-JobId: fake-job
    X-Debian-Tag2upload-Url: ???
    X-Debian-Tag2upload-Status: uploaded
    X-Debian-Tag2upload-Package: example
    To: Senatus Romanus <spqr@example.com>
    CC: copies@example.org
    Reply-To: reply-to@example.org,
        Senatus Romanus <spqr@example.com>
END

t-ok
