Skip to content

Commit

Permalink
Bugfixes and improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Lezurex committed Aug 8, 2021
1 parent c14d194 commit 9a97d5f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
1 change: 1 addition & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions .idea/sonarlint/issuestore/index.pb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ public ReleaseVersion(int major, int minor, int patch) {
}

public ReleaseVersion(String versionString) {

parseVersionString(versionString);
}

private void parseVersionString(String s) {
final Pattern pattern = Pattern.compile("[vV]?(\\d+)\\.?(\\d+)?\\.?(\\d+)?");
final Matcher matcher = pattern.matcher(s);

if (matcher.find()) {
for (int i = 1; i < matcher.groupCount(); i++) {
if (i == 1) this.major = Integer.parseInt(matcher.group());
if (i == 2) this.minor = Integer.parseInt(matcher.group());
if (i == 3) this.patch = Integer.parseInt(matcher.group());
for (int i = 1; i <= matcher.groupCount(); i++) {
if (i == 1) this.major = Integer.parseInt(matcher.group(i));
if (i == 2) this.minor = Integer.parseInt(matcher.group(i));
if (i == 3) this.patch = Integer.parseInt(matcher.group(i));
}
} else throw new InvalidVersionString(s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,14 @@ void setupInvalidRepo() {
assertThrows(RepoNotFoundException.class, () -> new GithubVersionChecker("Lezurex", "doesnotexist", releaseVersion), "Repo validation di not fail!");
}

@Test
@DisplayName("Check with outdated version")
void checkOutdated() {
ReleaseVersion releaseVersion = new ReleaseVersion("0.0.1");
GithubVersionChecker githubVersionChecker = new GithubVersionChecker("VoxCrafterLP", "JumpRace", releaseVersion);
CheckResult checkResult = githubVersionChecker.check();
assertEquals(VersionState.OUTDATED, checkResult.getVersionState(), "Version state is not outdated!");
assertTrue(checkResult.getPageLink().endsWith(checkResult.getVersion().toString()), "End of release URL does not match version!");
}

}

0 comments on commit 9a97d5f

Please sign in to comment.