Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/artipie/rpm-adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
olenagerasimova committed Oct 25, 2021
2 parents 2ce4002 + 0c6a39d commit 8629e49
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/artipie/rpm/pkg/HeaderTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static final class Version {
* Version format pattern.
*/
private static final Pattern PTRN =
Pattern.compile("((?<epoch>\\d+):)?(?<ver>[\\w.]+|^(?!.))(-(?<rel>.*))?");
Pattern.compile("((?<epoch>\\d+):)?(?<ver>[^/-]+|^(?!.))(-(?<rel>[^/-]*))?");

/**
* Value from version header.
Expand Down
16 changes: 11 additions & 5 deletions src/test/java/com/artipie/rpm/pkg/HeaderTagsVersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;
Expand All @@ -27,7 +26,8 @@ class HeaderTagsVersionTest {
"1.0.1-26.git20200127.fc32,1.0.1",
"2.0_1-2.jfh.sdd,2.0_1",
"2:9.0.2,9.0.2",
"1:1-9.878,1"
"1:1-9.878,1",
"2.9+9(7),2.9+9(7)"
})
void readsVersion(final String val, final String res) {
MatcherAssert.assertThat(
Expand Down Expand Up @@ -75,11 +75,17 @@ void returnsEmptyWhenRelIsNotPresent(final String val) {
);
}

@Test
void throwsExceptionWhenVersionNotValid() {
@ParameterizedTest
@ValueSource(strings = {
"-",
"3:sd/sd-2.3alpha",
"1/5",
"3:1-1-1"
})
void throwsExceptionWhenVersionNotValid(final String param) {
Assertions.assertThrows(
ArtipieException.class,
() -> new HeaderTags.Version("-").ver()
() -> new HeaderTags.Version(param).ver()
);
}

Expand Down

0 comments on commit 8629e49

Please sign in to comment.