Skip to content

Commit

Permalink
Add unit tests for changes validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
alerosmile authored and tcurdt committed Jan 8, 2025
1 parent cfc4c36 commit 324195a
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/test/java/org/vafer/jdeb/DebMakerTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 324195a

Please sign in to comment.