From 324195a34d194861e80702e3bf2e527a27b443db Mon Sep 17 00:00:00 2001 From: Roman Huber <26764588+alerosmile@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:40:50 +0100 Subject: [PATCH] Add unit tests for changes validation. --- .../java/org/vafer/jdeb/DebMakerTestCase.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/test/java/org/vafer/jdeb/DebMakerTestCase.java b/src/test/java/org/vafer/jdeb/DebMakerTestCase.java index 85027f7b7..3846ed782 100644 --- a/src/test/java/org/vafer/jdeb/DebMakerTestCase.java +++ b/src/test/java/org/vafer/jdeb/DebMakerTestCase.java @@ -305,6 +305,49 @@ public void testErrorPropagation() throws Exception { } } + @Test + public void testChangesValidation() throws Exception { + File deb = File.createTempFile("jdeb", ".deb"); + File changesSave = File.createTempFile("changesSave", ".txt"); + File directory = new File(getClass().getResource("deb/data").toURI()); + + DebMaker maker = new DebMaker(new NullConsole(), List.of(new UseNullAsInputStream()), null); + assertThrows(PackagingException.class, maker::validate); + + maker.setControl(new File(getClass().getResource("deb/control").toURI())); + assertThrows(PackagingException.class, maker::validate); + + maker.setDeb(deb); + maker.validate(); + + maker.setChangesEnabled(true); + maker.validate(); + + maker.setChangesIn(directory); + assertThrows(PackagingException.class, maker::validate); + + maker.setChangesIn(new File(getClass().getResource("changes/changes.txt").toURI())); + maker.validate(); + + maker.setChangesSave(directory); + assertThrows(PackagingException.class, maker::validate); + + maker.setChangesSave(null); + maker.setChangesOut(directory); + assertThrows(PackagingException.class, maker::validate); + + maker.setChangesOut(null); + maker.setChangesSave(changesSave); + maker.validate(); + + maker.setChangesIn(null); + assertThrows(PackagingException.class, maker::validate); + + maker.setChangesEnabled(false); + maker.setCompression(null); + assertThrows(PackagingException.class, maker::validate); + } + private DataProducer[] prepareData() throws URISyntaxException { File archive1 = new File(getClass().getResource("deb/data.tgz").toURI()); File archive2 = new File(getClass().getResource("deb/data.tar.bz2").toURI());