|
46 | 46 | import org.cactoos.scalar.Unchecked; |
47 | 47 | import org.hamcrest.MatcherAssert; |
48 | 48 | import org.hamcrest.core.IsEqual; |
| 49 | +import org.junit.jupiter.api.Assertions; |
| 50 | +import org.junit.jupiter.api.Disabled; |
49 | 51 | import org.junit.jupiter.api.Test; |
50 | 52 | import org.junit.jupiter.api.io.TempDir; |
51 | 53 |
|
52 | 54 | /** |
53 | 55 | * Unit tests for {@link Rpm}. |
54 | 56 | * |
55 | 57 | * @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. |
56 | 64 | * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) |
57 | 65 | */ |
58 | 66 | final class RpmTest { |
@@ -124,6 +132,26 @@ void doesntBrakeMetadataWhenInvalidPackageSentOnIncrementalUpdate(@TempDir final |
124 | 132 | ); |
125 | 133 | } |
126 | 134 |
|
| 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 | + |
127 | 155 | private static int countData(final Path path) throws IOException { |
128 | 156 | final Path primary = path.resolve("primary.xml"); |
129 | 157 | new Gzip(path.resolve(meta(path))).unpack(primary); |
|
0 commit comments