Skip to content

Commit 6565848

Browse files
committed
Test try-catch block for exception in UpdateTracker
1 parent 4a571da commit 6565848

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/test/java/dev/rusthero/versionchecker/tasks/UpdateTrackerTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,18 @@ void runWhenUpToDate() throws MalformedURLException {
3939
updateTracker.run();
4040
if (isOutdated.get() || isException.get()) fail();
4141
}
42+
43+
@Test
44+
void runWithInvalidRepo() throws MalformedURLException {
45+
GitHubVersionChecker versionChecker = new GitHubVersionChecker("rusthero", "this-repo-does-not-exist");
46+
Version version = new Version("1.0.0");
47+
48+
AtomicBoolean isOutdated = new AtomicBoolean(false);
49+
AtomicBoolean isException = new AtomicBoolean(false);
50+
UpdateTracker updateTracker = new UpdateTracker(versionChecker, version,
51+
latestVersion -> isOutdated.set(true),
52+
exception -> isException.set(true));
53+
updateTracker.run();
54+
if (isOutdated.get() || !isException.get()) fail();
55+
}
4256
}

0 commit comments

Comments
 (0)