Skip to content

Commit 324195a

Browse files
alerosmiletcurdt
authored andcommittedJan 8, 2025·
Add unit tests for changes validation.
1 parent cfc4c36 commit 324195a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
 

‎src/test/java/org/vafer/jdeb/DebMakerTestCase.java

+43
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,49 @@ public void testErrorPropagation() throws Exception {
305305
}
306306
}
307307

308+
@Test
309+
public void testChangesValidation() throws Exception {
310+
File deb = File.createTempFile("jdeb", ".deb");
311+
File changesSave = File.createTempFile("changesSave", ".txt");
312+
File directory = new File(getClass().getResource("deb/data").toURI());
313+
314+
DebMaker maker = new DebMaker(new NullConsole(), List.of(new UseNullAsInputStream()), null);
315+
assertThrows(PackagingException.class, maker::validate);
316+
317+
maker.setControl(new File(getClass().getResource("deb/control").toURI()));
318+
assertThrows(PackagingException.class, maker::validate);
319+
320+
maker.setDeb(deb);
321+
maker.validate();
322+
323+
maker.setChangesEnabled(true);
324+
maker.validate();
325+
326+
maker.setChangesIn(directory);
327+
assertThrows(PackagingException.class, maker::validate);
328+
329+
maker.setChangesIn(new File(getClass().getResource("changes/changes.txt").toURI()));
330+
maker.validate();
331+
332+
maker.setChangesSave(directory);
333+
assertThrows(PackagingException.class, maker::validate);
334+
335+
maker.setChangesSave(null);
336+
maker.setChangesOut(directory);
337+
assertThrows(PackagingException.class, maker::validate);
338+
339+
maker.setChangesOut(null);
340+
maker.setChangesSave(changesSave);
341+
maker.validate();
342+
343+
maker.setChangesIn(null);
344+
assertThrows(PackagingException.class, maker::validate);
345+
346+
maker.setChangesEnabled(false);
347+
maker.setCompression(null);
348+
assertThrows(PackagingException.class, maker::validate);
349+
}
350+
308351
private DataProducer[] prepareData() throws URISyntaxException {
309352
File archive1 = new File(getClass().getResource("deb/data.tgz").toURI());
310353
File archive2 = new File(getClass().getResource("deb/data.tar.bz2").toURI());

0 commit comments

Comments
 (0)
Please sign in to comment.