Skip to content

Commit

Permalink
New test EntryDetailsTest
Browse files Browse the repository at this point in the history
see ctron#42

Signed-off-by: Oliver Matz <[email protected]>
  • Loading branch information
OliverMatz committed Sep 13, 2019
1 parent 6ed50a1 commit 4a4c8b1
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/test/java/de/dentrassi/rpm/builder/EntryDetailsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package de.dentrassi.rpm.builder;

import org.eclipse.packager.rpm.FileFlags;
import org.eclipse.packager.rpm.build.FileInformation;
import org.junit.Test;

import java.util.Set;

import static org.junit.Assert.assertArrayEquals;

/**
* Test class de.dentrassi.rpm.builder.EntryDetails.
*/
public class EntryDetailsTest
{
/**
* Verify that empty {@link EntryDetails} result in empty set of {@link FileFlags}.
*/
@Test
public void applyEmpty()
{
final EntryDetails entryDetails = new EntryDetails();
doTest(new FileFlags[] {}, entryDetails);
}

/**
* Verify that {@link EntryDetails#setReadme(java.lang.Boolean)} correctly controls {@link FileFlags#README}.
*/
@Test
public void applyReadmeTrue()
{
final EntryDetails entryDetails = new EntryDetails();
entryDetails.setReadme(true);
doTest(new FileFlags[] {FileFlags.README}, entryDetails);
}

/**
* False negative? See https://github.com/ctron/rpm-builder/issues/42
*/
@Test
public void applyReadmeFalse()
{
final EntryDetails entryDetails = new EntryDetails();
entryDetails.setReadme(false);
doTest(new FileFlags[] {FileFlags.README}, entryDetails); // questionable
}

private static void doTest(FileFlags[] expectedResult, final EntryDetails entryDetails)
{
final FileInformation fileInformation = new FileInformation();
entryDetails.apply(fileInformation);
final Set<FileFlags> fileFlags = fileInformation.getFileFlags();
assertArrayEquals(expectedResult, fileFlags.toArray());
}
}

0 comments on commit 4a4c8b1

Please sign in to comment.