Skip to content

Commit

Permalink
Merge pull request #210 from paulodamaso/110
Browse files Browse the repository at this point in the history
For #110: Added meaningful error for broken package in Rpm.batchUpdate
  • Loading branch information
olenagerasimova committed Jun 17, 2020
2 parents 31f399c + 255415e commit c1edca1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/java/com/artipie/rpm/RpmTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,21 @@
import org.cactoos.scalar.Unchecked;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/**
* Unit tests for {@link Rpm}.
*
* @since 0.9
* @todo #110:30min Meaningful error on broken package.
* Rpm should throw an exception when trying to add an invalid package.
* The type of exception must be IllegalArgumentException and its message
* "Reading of RPM package 'package' failed, data corrupt or malformed.",
* like described in showMeaningfulErrorWhenInvalidPackageSent. Implement it
* and then enable the test.
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
final class RpmTest {
Expand Down Expand Up @@ -124,6 +132,26 @@ void doesntBrakeMetadataWhenInvalidPackageSentOnIncrementalUpdate(@TempDir final
);
}

@Test
@Disabled
void showMeaningfulErrorWhenInvalidPackageSent() throws Exception {
final Storage storage = new InMemoryStorage();
final Rpm repo = new Rpm(
storage, StandardNamingPolicy.SHA1, Digest.SHA256, true
);
new TestRpm.Multiple(
new TestRpm.Abc(),
new TestRpm.Libdeflt()
).put(storage);
repo.batchUpdate(Key.ROOT).blockingAwait();
new TestRpm.Invalid().put(storage);
Assertions.assertThrows(
IllegalArgumentException.class,
() -> repo.batchUpdate(Key.ROOT).blockingAwait(),
"Reading of RPM package \"brokentwo.rpm\" failed, data corrupt or malformed."
);
}

private static int countData(final Path path) throws IOException {
final Path primary = path.resolve("primary.xml");
new Gzip(path.resolve(meta(path))).unpack(primary);
Expand Down

1 comment on commit c1edca1

@0pdd
Copy link

@0pdd 0pdd commented on c1edca1 Jun 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 110-69218d91 discovered in src/test/java/com/artipie/rpm/RpmTest.java and submitted as #268. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.