From 02ea4c058444fc8fbbc084eee12fef54dd58c28e Mon Sep 17 00:00:00 2001
From: Andrej Shadura <andrew.shadura@collabora.co.uk>
Date: Tue, 2 Feb 2021 10:54:31 +0100
Subject: [PATCH] Add a basic test of apertis-pkg-merge-updates functionality

This will try to merge an "update" of dash on a completely made-up
package history. There are two fixtures, sharing common parts. They
both:

* Start with an ancient dash version from Lenny, 0.5.4-12.
* This version is imported as 0.5.4-12co0 into an imaginary
  Apertis version.
* A "new" version of dash, 0.5.10.2-1 is imported from a 2018
  cut of Buster.
* This new version is merged into Apertis as 0.5.10.2-1co0

From this point, the "modified" fixture differs:
* An imaginary Apertis developer changes the compat level in
  the imported version from 10 to 11, thus introducing a delta
  which however is not going to conflict with any further version
  of dash in Buster.

apertis-pkg-merge-updates is expected to merge the update into the
"unmodified" repository as 0.5.10.2-5co0 and finalise the changelog.

For the "modified" repository, it should import the update as
0.5.10.2-5co1, add "PLEASE SUMMARIZE remaining Apertis changes" note
to the top entry and leave it UNRELEASED.

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
---
 .gitlab-ci.yml | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b5c44e7..a660bb1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -119,6 +119,33 @@ build-package-source-builder-docker-image:
   variables:
     image: package-source-builder
 
+test-package-source-builder:
+  stage: image test
+  needs:
+    - build-package-source-builder-docker-image
+  image:
+    name: $CI_REGISTRY_IMAGE/${RELEASE}-package-source-builder:${TEST_TAG}
+    entrypoint: [ "" ]
+  script:
+    - git clone https://gitlab.apertis.org/infrastructure/test-data/fixture-dash-unmodified
+    - ": Verify we correctly detect when there are no local changes and use the co0 suffix"
+    - cd fixture-dash-unmodified
+    - apertis-pkg-merge-updates --package dash --upstream debian/buster --downstream apertis/v2020dev0
+    - git log --graph --oneline --decorate
+    - git diff debian/buster..
+    - test "$(dpkg-parsechangelog -SVersion)" = 0.5.10.2-5co0
+    - test "$(dpkg-parsechangelog -SDistribution)" = apertis
+    - cd ..
+    - git clone https://gitlab.apertis.org/infrastructure/test-data/fixture-dash-modified
+    - ": Verify we correctly detect local changes and do not finalise the changelog"
+    - cd fixture-dash-modified
+    - apertis-pkg-merge-updates --package dash --upstream debian/buster --downstream apertis/v2020dev0
+    - git log --graph --oneline --decorate
+    - git diff debian/buster..
+    - test "$(dpkg-parsechangelog -SVersion)" = 0.5.10.2-5co1
+    - test "$(dpkg-parsechangelog -SDistribution)" = UNRELEASED
+    - cd ..
+
 build-documentation-builder-docker-image:
   extends: .build-docker-image
   stage: derived images
-- 
GitLab