From 54a519b062e9b6b7220a39d7978956bf4605a301 Mon Sep 17 00:00:00 2001 From: KereMath Date: Thu, 20 Aug 2026 11:07:06 +0300 Subject: [PATCH] tests: cover skel files with multiple components at unit level Regression test for the duplicated skel payload: publishing two components used to append each skeleton file once per component. Fails against the previous code with doubled file contents, mirroring the PublishRepo40Test system test at unit level. --- deb/publish_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/deb/publish_test.go b/deb/publish_test.go index a6db7526..12d858d2 100644 --- a/deb/publish_test.go +++ b/deb/publish_test.go @@ -634,6 +634,32 @@ func (s *PublishedRepoSuite) TestPublishSkelFiles(c *C) { c.Check(st["SHA256"], Matches, "(?s).*main/extra/metadata\\.json.*") } +func (s *PublishedRepoSuite) TestPublishSkelFilesMultipleComponents(c *C) { + // regression test: skel files used to be emitted once per component, + // appending each payload to the index again (issue fixed in this change) + skelDir := c.MkDir() + mainDir := filepath.Join(skelDir, "linux", "dists", "natty", "main") + contribDir := filepath.Join(skelDir, "linux", "dists", "natty", "contrib") + c.Assert(os.MkdirAll(mainDir, 0755), IsNil) + c.Assert(os.MkdirAll(contribDir, 0755), IsNil) + c.Assert(os.WriteFile(filepath.Join(mainDir, "main.txt"), []byte("skel for main\n"), 0644), IsNil) + c.Assert(os.WriteFile(filepath.Join(contribDir, "contrib.txt"), []byte("skel for contrib\n"), 0644), IsNil) + + err := s.repo3.Publish(s.packagePool, s.provider, s.factory, &NullSigner{}, nil, false, skelDir) + c.Assert(err, IsNil) + + base := filepath.Join(s.publishedStorage.PublicPath(), "linux/dists/natty") + + // each payload must be published exactly once, not duplicated per component + published, err := os.ReadFile(filepath.Join(base, "main/main.txt")) + c.Assert(err, IsNil) + c.Check(string(published), Equals, "skel for main\n") + + published, err = os.ReadFile(filepath.Join(base, "contrib/contrib.txt")) + c.Assert(err, IsNil) + c.Check(string(published), Equals, "skel for contrib\n") +} + func (s *PublishedRepoSuite) TestPublishSkelFilesWalkError(c *C) { if runtime.GOOS == "windows" { c.Skip("a file in the middle of a path is reported as not-exist on Windows")