Skip to content

Commit c1edca1

Browse files
Merge pull request #210 from paulodamaso/110
For #110: Added meaningful error for broken package in Rpm.batchUpdate
2 parents 31f399c + 255415e commit c1edca1

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/test/java/com/artipie/rpm/RpmTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,21 @@
4646
import org.cactoos.scalar.Unchecked;
4747
import org.hamcrest.MatcherAssert;
4848
import org.hamcrest.core.IsEqual;
49+
import org.junit.jupiter.api.Assertions;
50+
import org.junit.jupiter.api.Disabled;
4951
import org.junit.jupiter.api.Test;
5052
import org.junit.jupiter.api.io.TempDir;
5153

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

135+
@Test
136+
@Disabled
137+
void showMeaningfulErrorWhenInvalidPackageSent() throws Exception {
138+
final Storage storage = new InMemoryStorage();
139+
final Rpm repo = new Rpm(
140+
storage, StandardNamingPolicy.SHA1, Digest.SHA256, true
141+
);
142+
new TestRpm.Multiple(
143+
new TestRpm.Abc(),
144+
new TestRpm.Libdeflt()
145+
).put(storage);
146+
repo.batchUpdate(Key.ROOT).blockingAwait();
147+
new TestRpm.Invalid().put(storage);
148+
Assertions.assertThrows(
149+
IllegalArgumentException.class,
150+
() -> repo.batchUpdate(Key.ROOT).blockingAwait(),
151+
"Reading of RPM package \"brokentwo.rpm\" failed, data corrupt or malformed."
152+
);
153+
}
154+
127155
private static int countData(final Path path) throws IOException {
128156
final Path primary = path.resolve("primary.xml");
129157
new Gzip(path.resolve(meta(path))).unpack(primary);

0 commit comments

Comments
 (0)